setwd("C:/Users/jwils/OneDrive/Documents/Grad_Studies/Microbial_Leaf_Spec_Project/microbe_data/MiSeq_data/MiSeq_16S/Phenology")
if (!require(“BiocManager”, quietly = TRUE)) install.packages(“BiocManager”) BiocManager::install()
if (!require(“BiocManager”, quietly = TRUE)) install.packages(“BiocManager”)
BiocManager::install(“BiocVersion”)
BiocManager::install()
BiocManager::available()
if (!require(“BiocManager”, quietly = TRUE)) install.packages(“BiocManager”) BiocManager::install(version = “3.18”)
BiocManager::install(“dada2”)
install.packages(“devtools”) library(“devtools”) devtools::install_github(“benjjneb/dada2”, ref=“v1.8”) # change the ref argument to get other versions
Back to TOC ################################################################################
install.packages(“Biostrings”) install.packages(“matrixStats”) install.packages(“ShortRead”)
library(BiocManager)
library(dada2)
library(matrixStats)
library(ShortRead)
library(Biostrings)
library(Matrix)
packageVersion("dada2")
## [1] '1.34.0'
packageVersion("ShortRead")
## [1] '1.64.0'
packageVersion("Biostrings")
## [1] '2.74.0'
packageVersion("BiocManager")
## [1] '1.30.25'
packageVersion("Matrix")
## [1] '1.7.1'
path <- "C:/Users/jwils/OneDrive/Documents/Grad_Studies/Microbial_Leaf_Spec_Project/microbe_data/MiSeq_data/MiSeq_16S/Phenology"
list.files(path)
## [1] "16S_analyses_full_workspace.RData"
## [2] "16S_analyses_full_workspace.RDataTmp"
## [3] "16S_dada2_phenology_analyses.md"
## [4] "16S_dada2_phenology_analyses.R"
## [5] "16S_dada2_phenology_analyses.Rmd"
## [6] "16S_phenology_analyses_final.Rmd"
## [7] "16S_phenology_analyses_full.html"
## [8] "16S_phenology_analyses_full.knit.md"
## [9] "16S_phenology_analyses_full.RData"
## [10] "16S_phenology_analyses_full.Rmd"
## [11] "16S_phenology_analyses_full_BACKUP.Rmd"
## [12] "16S_phenology_analyses_full_CLEAN.Rmd"
## [13] "16S_phenology_analyses_full_CLEAN_v2.html"
## [14] "16S_phenology_analyses_full_CLEAN_v2.Rmd"
## [15] "16S_phenology_analyses_full_CLEAN_v3.Rmd"
## [16] "16S_phenology_analyses_full_CLEAN_v4.Rmd"
## [17] "16S_phenology_analyses_full_CLEAN_with_RDA.Rmd"
## [18] "16S_phenology_analyses_full_files"
## [19] "16S_Phenology_Functional_Trait_Analyses.Rmd"
## [20] "16S_stats_summary.xlsx"
## [21] "16S_unused_analyses.Rmd"
## [22] "16S_without_samples.Rmd"
## [23] "alpha_inter_combined.jpg"
## [24] "alpha_inter_combined2.tiff"
## [25] "asv_ag.csv"
## [26] "ASV_richness_alpha_phen"
## [27] "asv_scaled_noPlants.csv"
## [28] "asv_scaled_noPlants_filtered.csv"
## [29] "asv_scaled_noPlants_Phen_filt_LMM.csv"
## [30] "asv_scaled_noPlants_Phenology_filtered.csv"
## [31] "asv_traits_abs.csv"
## [32] "asv_traits_joined.csv"
## [33] "asv_traits_ref.csv"
## [34] "asv_traits_trans.csv"
## [35] "ASVrich_phenology_16S.jpeg"
## [36] "betaDiv_intra_combined.jpg"
## [37] "betaDiv_intra_combined_gdds.jpg"
## [38] "betaDiv_intra_combined_labelled.jpg"
## [39] "betaDiv_intra_combined_phen.jpg"
## [40] "betaDiv_intra_combined_traits.pdf"
## [41] "betaDiv_intra_combined_traits.png"
## [42] "betaDiv_intra_combined_traits.tiff"
## [43] "betula_comp_gdd_legend_sp.png"
## [44] "betula_comp_gdd_phyla2.png"
## [45] "betula_comp_gdd_plot_sp.png"
## [46] "betula_composition_final.png"
## [47] "betula_data.csv"
## [48] "betula_disper_gdd_boxplot.png"
## [49] "betula_disper_gdd_pcoa.png"
## [50] "betula_disper_plantid_boxplot.png"
## [51] "betula_disper_plantid_pcoa.png"
## [52] "betula_gen_composition_final.png"
## [53] "CABO_samples_2022-10-27-MetaData-v1.xlsx"
## [54] "CABO_samples_2022-10-27-MetaData-v2.xlsx"
## [55] "CABO_samples_2022-10-27-MetaData-v3.xlsx"
## [56] "combined_abund_genus_plot.pdf"
## [57] "combined_abund_genus_plot.png"
## [58] "combined_legends.pdf"
## [59] "combined_legends.png"
## [60] "combined_relative_abundances.csv"
## [61] "combined_specaccum_plots.jpg"
## [62] "dada2_output_field.RData"
## [63] "deseq_combined_gen_phy.jpg"
## [64] "deseq_combined_gen_phy_bubble.pdf"
## [65] "deseq_combined_gen_phy_bubble.png"
## [66] "deseq_combined_gen_phy_bubble.tiff"
## [67] "deseq_combined_gen_phy_labels.jpg"
## [68] "deseq_genus_combined_cont_trend.jpg"
## [69] "deseq_genus_combined_cont_trend.pdf"
## [70] "deseq_genus_combined_cont_trend.png"
## [71] "deseq_genus_combined_cont_trend.tiff"
## [72] "deseq_genus_combined_cont_trend2.pdf"
## [73] "deseq_genus_combined_cont_trend2.png"
## [74] "deseq_phylum_combined_cont_trend.jpg"
## [75] "deseq_phylum_combined_cont_trend.pdf"
## [76] "deseq_phylum_combined_cont_trend.png"
## [77] "deseq_phylum_combined_cont_trend.tiff"
## [78] "deseq_phylum_combined_cont_trend2.pdf"
## [79] "deseq_phylum_combined_cont_trend2.png"
## [80] "deseq_phylum_combined_cont_trend2.tiff"
## [81] "deseq_plot1087_genus.png"
## [82] "deseq_plot1606_genus.png"
## [83] "deseq_plot1992_genus.png"
## [84] "deseq_plot2140_genus.png"
## [85] "deseq_plot2219_genus.png"
## [86] "deseq_plot437_genus.png"
## [87] "deseq_plot605_genus.png"
## [88] "deseq_plots_genus_combined_bubble.pdf"
## [89] "deseq_plots_genus_combined_bubble.png"
## [90] "deseq_plots_genus_combined_label.jpg"
## [91] "deseq_plots_genus_phylum_combined.png"
## [92] "deseq_plots_phylum_combined_labels.jpg"
## [93] "deseq_plots_phylum_labels.jpg"
## [94] "desktop.ini"
## [95] "df_ps_phen_asv_lmm.csv"
## [96] "diff_abund_barplot_genus.jpg"
## [97] "diff_abund_barplot_phylum.pdf"
## [98] "diff_abund_barplot_phylum_interact.pdf"
## [99] "diff_abund_interaction_barplot.pdf"
## [100] "diff_abund_results.xlsx"
## [101] "diffabund_heatmap_output.pdf"
## [102] "ex_l2.csv"
## [103] "fig_div_combined_traits.pdf"
## [104] "fig_div_combined_traits.png"
## [105] "fig_div_combined_traits.tiff"
## [106] "fig_div_combined1.png"
## [107] "fig_div_combined1.tiff"
## [108] "fig_div_combined2.pdf"
## [109] "fig_div_combined2.png"
## [110] "fig_div_combined2.tif"
## [111] "fig_div_combined2.tiff"
## [112] "fig_taxa_deseq_combined.png"
## [113] "fig_taxa_deseq_combined.tiff"
## [114] "fig_taxa_deseq_combined_bubble.pdf"
## [115] "fig_taxa_deseq_combined_bubble.png"
## [116] "fig_taxa_deseq_combined_bubble.tiff"
## [117] "fig_taxa_deseq_combined_bubble2.png"
## [118] "fig_taxa_deseq_combined_bubble2.tiff"
## [119] "Figs_Journal_FINAL"
## [120] "FigsTables_Final"
## [121] "filtered"
## [122] "filtN"
## [123] "final_asv_table.csv"
## [124] "final_asv_table.txt"
## [125] "final_asv_table_bet_cont_trend.csv"
## [126] "final_asv_table_bet_cont_trend.txt"
## [127] "final_asv_table_interaction.csv"
## [128] "final_asv_table_interaction.txt"
## [129] "final_asv_table_LMM.csv"
## [130] "final_asv_table_LMM.txt"
## [131] "final_asv_table_pop_cont_trend.csv"
## [132] "final_asv_table_pop_cont_trend.csv.txt"
## [133] "final_asv_table_spp_LMM_1087.csv"
## [134] "final_asv_table_spp_LMM_1087.txt"
## [135] "final_asv_table_spp_LMM_1606.csv"
## [136] "final_asv_table_spp_LMM_1606.txt"
## [137] "final_asv_table_spp_LMM_1992.csv"
## [138] "final_asv_table_spp_LMM_1992.txt"
## [139] "final_asv_table_spp_LMM_2140.csv"
## [140] "final_asv_table_spp_LMM_2140.txt"
## [141] "final_asv_table_spp_LMM_2219.csv"
## [142] "final_asv_table_spp_LMM_2219.txt"
## [143] "final_asv_table_spp_LMM_437.csv"
## [144] "final_asv_table_spp_LMM_437.txt"
## [145] "final_asv_table_spp_LMM_605.csv"
## [146] "final_asv_table_spp_LMM_605.txt"
## [147] "final_table_bet_cont_trend.csv"
## [148] "final_table_bet_cont_trend.txt"
## [149] "final_table_betula_vs_populus.csv"
## [150] "final_table_betula_vs_populus.txt"
## [151] "final_table_betula_vs_populus_interaction.csv"
## [152] "final_table_betula_vs_populus_interaction.txt"
## [153] "final_table_betula_vs_populus_LMM.csv"
## [154] "final_table_betula_vs_populus_LMM.txt"
## [155] "final_table_betula_vs_populus_LMM_1087.csv"
## [156] "final_table_betula_vs_populus_LMM_1087.txt"
## [157] "final_table_betula_vs_populus_LMM_1606.csv"
## [158] "final_table_betula_vs_populus_LMM_1606.txt"
## [159] "final_table_betula_vs_populus_LMM_1992.csv"
## [160] "final_table_betula_vs_populus_LMM_1992.txt"
## [161] "final_table_betula_vs_populus_LMM_2140.csv"
## [162] "final_table_betula_vs_populus_LMM_2140.txt"
## [163] "final_table_betula_vs_populus_LMM_2219.csv"
## [164] "final_table_betula_vs_populus_LMM_2219.txt"
## [165] "final_table_betula_vs_populus_LMM_437.csv"
## [166] "final_table_betula_vs_populus_LMM_437.txt"
## [167] "final_table_betula_vs_populus_LMM_605.csv"
## [168] "final_table_betula_vs_populus_LMM_605.txt"
## [169] "final_table_pop_cont_trend.csv"
## [170] "final_table_pop_cont_trend.txt"
## [171] "gdd_vs_time_plot2.png"
## [172] "gdd_vs_time_plot2.tiff"
## [173] "Genus_GDD_Effects.csv"
## [174] "homogeneity_plots_untransformed.jpg"
## [175] "interaction_disper_boxplot.png"
## [176] "interaction_multivar_boxplot.jpg"
## [177] "ITS_dada2_phenology_analyses.R"
## [178] "legend_bet_gen_cont_trend.png"
## [179] "legend_bet_phy_cont_trend.png"
## [180] "legend_pop_gen_cont_trend.png"
## [181] "MI.M05812_0306.001.FLD_ill_002_i7---IDT_i5_10.CABO_109_16S_I1.fastq"
## [182] "MI.M05812_0306.001.FLD_ill_002_i7---IDT_i5_10.CABO_109_16S_I2.fastq"
## [183] "MI.M05812_0306.001.FLD_ill_002_i7---IDT_i5_10.CABO_109_16S_R1.fastq"
## [184] "MI.M05812_0306.001.FLD_ill_002_i7---IDT_i5_10.CABO_109_16S_R2.fastq"
## [185] "MI.M05812_0306.001.FLD_ill_003_i7---IDT_i5_10.CABO_121_16S_I1.fastq"
## [186] "MI.M05812_0306.001.FLD_ill_003_i7---IDT_i5_10.CABO_121_16S_I2.fastq"
## [187] "MI.M05812_0306.001.FLD_ill_003_i7---IDT_i5_10.CABO_121_16S_R1.fastq"
## [188] "MI.M05812_0306.001.FLD_ill_003_i7---IDT_i5_10.CABO_121_16S_R2.fastq"
## [189] "MI.M05812_0306.001.FLD_ill_003_i7---IDT_i5_9.CABO_025_16S_I1.fastq"
## [190] "MI.M05812_0306.001.FLD_ill_003_i7---IDT_i5_9.CABO_025_16S_I2.fastq"
## [191] "MI.M05812_0306.001.FLD_ill_003_i7---IDT_i5_9.CABO_025_16S_R1.fastq"
## [192] "MI.M05812_0306.001.FLD_ill_003_i7---IDT_i5_9.CABO_025_16S_R2.fastq"
## [193] "MI.M05812_0306.001.FLD_ill_004_i7---IDT_i5_9.CABO_037_16S_I1.fastq"
## [194] "MI.M05812_0306.001.FLD_ill_004_i7---IDT_i5_9.CABO_037_16S_I2.fastq"
## [195] "MI.M05812_0306.001.FLD_ill_004_i7---IDT_i5_9.CABO_037_16S_R1.fastq"
## [196] "MI.M05812_0306.001.FLD_ill_004_i7---IDT_i5_9.CABO_037_16S_R2.fastq"
## [197] "MI.M05812_0306.001.FLD_ill_005_i7---IDT_i5_10.CABO_145_16S_I1.fastq"
## [198] "MI.M05812_0306.001.FLD_ill_005_i7---IDT_i5_10.CABO_145_16S_I2.fastq"
## [199] "MI.M05812_0306.001.FLD_ill_005_i7---IDT_i5_10.CABO_145_16S_R1.fastq"
## [200] "MI.M05812_0306.001.FLD_ill_005_i7---IDT_i5_10.CABO_145_16S_R2.fastq"
## [201] "MI.M05812_0306.001.FLD_ill_009_i7---IDT_i5_10.CABO_002_16S_I1.fastq"
## [202] "MI.M05812_0306.001.FLD_ill_009_i7---IDT_i5_10.CABO_002_16S_I2.fastq"
## [203] "MI.M05812_0306.001.FLD_ill_009_i7---IDT_i5_10.CABO_002_16S_R1.fastq"
## [204] "MI.M05812_0306.001.FLD_ill_009_i7---IDT_i5_10.CABO_002_16S_R2.fastq"
## [205] "MI.M05812_0306.001.FLD_ill_010_i7---IDT_i5_10.CABO_014_16S_I1.fastq"
## [206] "MI.M05812_0306.001.FLD_ill_010_i7---IDT_i5_10.CABO_014_16S_I2.fastq"
## [207] "MI.M05812_0306.001.FLD_ill_010_i7---IDT_i5_10.CABO_014_16S_R1.fastq"
## [208] "MI.M05812_0306.001.FLD_ill_010_i7---IDT_i5_10.CABO_014_16S_R2.fastq"
## [209] "MI.M05812_0306.001.FLD_ill_010_i7---IDT_i5_11.CABO_110_16S_I1.fastq"
## [210] "MI.M05812_0306.001.FLD_ill_010_i7---IDT_i5_11.CABO_110_16S_I2.fastq"
## [211] "MI.M05812_0306.001.FLD_ill_010_i7---IDT_i5_11.CABO_110_16S_R1.fastq"
## [212] "MI.M05812_0306.001.FLD_ill_010_i7---IDT_i5_11.CABO_110_16S_R2.fastq"
## [213] "MI.M05812_0306.001.FLD_ill_011_i7---IDT_i5_10.CABO_026_16S_I1.fastq"
## [214] "MI.M05812_0306.001.FLD_ill_011_i7---IDT_i5_10.CABO_026_16S_I2.fastq"
## [215] "MI.M05812_0306.001.FLD_ill_011_i7---IDT_i5_10.CABO_026_16S_R1.fastq"
## [216] "MI.M05812_0306.001.FLD_ill_011_i7---IDT_i5_10.CABO_026_16S_R2.fastq"
## [217] "MI.M05812_0306.001.FLD_ill_012_i7---IDT_i5_10.CABO_038_16S_I1.fastq"
## [218] "MI.M05812_0306.001.FLD_ill_012_i7---IDT_i5_10.CABO_038_16S_I2.fastq"
## [219] "MI.M05812_0306.001.FLD_ill_012_i7---IDT_i5_10.CABO_038_16S_R1.fastq"
## [220] "MI.M05812_0306.001.FLD_ill_012_i7---IDT_i5_10.CABO_038_16S_R2.fastq"
## [221] "MI.M05812_0306.001.FLD_ill_013_i7---IDT_i5_11.CABO_146_16S_I1.fastq"
## [222] "MI.M05812_0306.001.FLD_ill_013_i7---IDT_i5_11.CABO_146_16S_I2.fastq"
## [223] "MI.M05812_0306.001.FLD_ill_013_i7---IDT_i5_11.CABO_146_16S_R1.fastq"
## [224] "MI.M05812_0306.001.FLD_ill_013_i7---IDT_i5_11.CABO_146_16S_R2.fastq"
## [225] "MI.M05812_0306.001.FLD_ill_017_i7---IDT_i5_1.CABO_183_16S_I1.fastq"
## [226] "MI.M05812_0306.001.FLD_ill_017_i7---IDT_i5_1.CABO_183_16S_I2.fastq"
## [227] "MI.M05812_0306.001.FLD_ill_017_i7---IDT_i5_1.CABO_183_16S_R1.fastq"
## [228] "MI.M05812_0306.001.FLD_ill_017_i7---IDT_i5_1.CABO_183_16S_R2.fastq"
## [229] "MI.M05812_0306.001.FLD_ill_017_i7---IDT_i5_11.CABO_003_16S_I1.fastq"
## [230] "MI.M05812_0306.001.FLD_ill_017_i7---IDT_i5_11.CABO_003_16S_I2.fastq"
## [231] "MI.M05812_0306.001.FLD_ill_017_i7---IDT_i5_11.CABO_003_16S_R1.fastq"
## [232] "MI.M05812_0306.001.FLD_ill_017_i7---IDT_i5_11.CABO_003_16S_R2.fastq"
## [233] "MI.M05812_0306.001.FLD_ill_019_i7---IDT_i5_11.CABO_027_16S_I1.fastq"
## [234] "MI.M05812_0306.001.FLD_ill_019_i7---IDT_i5_11.CABO_027_16S_I2.fastq"
## [235] "MI.M05812_0306.001.FLD_ill_019_i7---IDT_i5_11.CABO_027_16S_R1.fastq"
## [236] "MI.M05812_0306.001.FLD_ill_019_i7---IDT_i5_11.CABO_027_16S_R2.fastq"
## [237] "MI.M05812_0306.001.FLD_ill_020_i7---IDT_i5_11.CABO_039_16S_I1.fastq"
## [238] "MI.M05812_0306.001.FLD_ill_020_i7---IDT_i5_11.CABO_039_16S_I2.fastq"
## [239] "MI.M05812_0306.001.FLD_ill_020_i7---IDT_i5_11.CABO_039_16S_R1.fastq"
## [240] "MI.M05812_0306.001.FLD_ill_020_i7---IDT_i5_11.CABO_039_16S_R2.fastq"
## [241] "MI.M05812_0306.001.FLD_ill_021_i7---IDT_i5_11.CABO_051_16S_I1.fastq"
## [242] "MI.M05812_0306.001.FLD_ill_021_i7---IDT_i5_11.CABO_051_16S_I2.fastq"
## [243] "MI.M05812_0306.001.FLD_ill_021_i7---IDT_i5_11.CABO_051_16S_R1.fastq"
## [244] "MI.M05812_0306.001.FLD_ill_021_i7---IDT_i5_11.CABO_051_16S_R2.fastq"
## [245] "MI.M05812_0306.001.FLD_ill_021_i7---IDT_i5_12.CABO_147_16S_I1.fastq"
## [246] "MI.M05812_0306.001.FLD_ill_021_i7---IDT_i5_12.CABO_147_16S_I2.fastq"
## [247] "MI.M05812_0306.001.FLD_ill_021_i7---IDT_i5_12.CABO_147_16S_R1.fastq"
## [248] "MI.M05812_0306.001.FLD_ill_021_i7---IDT_i5_12.CABO_147_16S_R2.fastq"
## [249] "MI.M05812_0306.001.FLD_ill_025_i7---IDT_i5_2.CABO_184_16S_I1.fastq"
## [250] "MI.M05812_0306.001.FLD_ill_025_i7---IDT_i5_2.CABO_184_16S_I2.fastq"
## [251] "MI.M05812_0306.001.FLD_ill_025_i7---IDT_i5_2.CABO_184_16S_R1.fastq"
## [252] "MI.M05812_0306.001.FLD_ill_025_i7---IDT_i5_2.CABO_184_16S_R2.fastq"
## [253] "MI.M05812_0306.001.FLD_ill_026_i7---IDT_i5_1.CABO_112_16S_I1.fastq"
## [254] "MI.M05812_0306.001.FLD_ill_026_i7---IDT_i5_1.CABO_112_16S_I2.fastq"
## [255] "MI.M05812_0306.001.FLD_ill_026_i7---IDT_i5_1.CABO_112_16S_R1.fastq"
## [256] "MI.M05812_0306.001.FLD_ill_026_i7---IDT_i5_1.CABO_112_16S_R2.fastq"
## [257] "MI.M05812_0306.001.FLD_ill_027_i7---IDT_i5_1.CABO_124_16S_I1.fastq"
## [258] "MI.M05812_0306.001.FLD_ill_027_i7---IDT_i5_1.CABO_124_16S_I2.fastq"
## [259] "MI.M05812_0306.001.FLD_ill_027_i7---IDT_i5_1.CABO_124_16S_R1.fastq"
## [260] "MI.M05812_0306.001.FLD_ill_027_i7---IDT_i5_1.CABO_124_16S_R2.fastq"
## [261] "MI.M05812_0306.001.FLD_ill_027_i7---IDT_i5_12.CABO_028_16S_I1.fastq"
## [262] "MI.M05812_0306.001.FLD_ill_027_i7---IDT_i5_12.CABO_028_16S_I2.fastq"
## [263] "MI.M05812_0306.001.FLD_ill_027_i7---IDT_i5_12.CABO_028_16S_R1.fastq"
## [264] "MI.M05812_0306.001.FLD_ill_027_i7---IDT_i5_12.CABO_028_16S_R2.fastq"
## [265] "MI.M05812_0306.001.FLD_ill_028_i7---IDT_i5_12.CABO_040_16S_I1.fastq"
## [266] "MI.M05812_0306.001.FLD_ill_028_i7---IDT_i5_12.CABO_040_16S_I2.fastq"
## [267] "MI.M05812_0306.001.FLD_ill_028_i7---IDT_i5_12.CABO_040_16S_R1.fastq"
## [268] "MI.M05812_0306.001.FLD_ill_028_i7---IDT_i5_12.CABO_040_16S_R2.fastq"
## [269] "MI.M05812_0306.001.FLD_ill_029_i7---IDT_i5_1.CABO_148_16S_I1.fastq"
## [270] "MI.M05812_0306.001.FLD_ill_029_i7---IDT_i5_1.CABO_148_16S_I2.fastq"
## [271] "MI.M05812_0306.001.FLD_ill_029_i7---IDT_i5_1.CABO_148_16S_R1.fastq"
## [272] "MI.M05812_0306.001.FLD_ill_029_i7---IDT_i5_1.CABO_148_16S_R2.fastq"
## [273] "MI.M05812_0306.001.FLD_ill_031_i7---IDT_i5_12.CABO_076_16S_I1.fastq"
## [274] "MI.M05812_0306.001.FLD_ill_031_i7---IDT_i5_12.CABO_076_16S_I2.fastq"
## [275] "MI.M05812_0306.001.FLD_ill_031_i7---IDT_i5_12.CABO_076_16S_R1.fastq"
## [276] "MI.M05812_0306.001.FLD_ill_031_i7---IDT_i5_12.CABO_076_16S_R2.fastq"
## [277] "MI.M05812_0306.001.FLD_ill_033_i7---IDT_i5_2.CABO_101_16S_I1.fastq"
## [278] "MI.M05812_0306.001.FLD_ill_033_i7---IDT_i5_2.CABO_101_16S_I2.fastq"
## [279] "MI.M05812_0306.001.FLD_ill_033_i7---IDT_i5_2.CABO_101_16S_R1.fastq"
## [280] "MI.M05812_0306.001.FLD_ill_033_i7---IDT_i5_2.CABO_101_16S_R2.fastq"
## [281] "MI.M05812_0306.001.FLD_ill_033_i7---IDT_i5_3.CABO_185_16S_I1.fastq"
## [282] "MI.M05812_0306.001.FLD_ill_033_i7---IDT_i5_3.CABO_185_16S_I2.fastq"
## [283] "MI.M05812_0306.001.FLD_ill_033_i7---IDT_i5_3.CABO_185_16S_R1.fastq"
## [284] "MI.M05812_0306.001.FLD_ill_033_i7---IDT_i5_3.CABO_185_16S_R2.fastq"
## [285] "MI.M05812_0306.001.FLD_ill_034_i7---IDT_i5_2.CABO_113_16S_I1.fastq"
## [286] "MI.M05812_0306.001.FLD_ill_034_i7---IDT_i5_2.CABO_113_16S_I2.fastq"
## [287] "MI.M05812_0306.001.FLD_ill_034_i7---IDT_i5_2.CABO_113_16S_R1.fastq"
## [288] "MI.M05812_0306.001.FLD_ill_034_i7---IDT_i5_2.CABO_113_16S_R2.fastq"
## [289] "MI.M05812_0306.001.FLD_ill_035_i7---IDT_i5_1.CABO_029_16S_I1.fastq"
## [290] "MI.M05812_0306.001.FLD_ill_035_i7---IDT_i5_1.CABO_029_16S_I2.fastq"
## [291] "MI.M05812_0306.001.FLD_ill_035_i7---IDT_i5_1.CABO_029_16S_R1.fastq"
## [292] "MI.M05812_0306.001.FLD_ill_035_i7---IDT_i5_1.CABO_029_16S_R2.fastq"
## [293] "MI.M05812_0306.001.FLD_ill_035_i7---IDT_i5_2.CABO_125_16S_I1.fastq"
## [294] "MI.M05812_0306.001.FLD_ill_035_i7---IDT_i5_2.CABO_125_16S_I2.fastq"
## [295] "MI.M05812_0306.001.FLD_ill_035_i7---IDT_i5_2.CABO_125_16S_R1.fastq"
## [296] "MI.M05812_0306.001.FLD_ill_035_i7---IDT_i5_2.CABO_125_16S_R2.fastq"
## [297] "MI.M05812_0306.001.FLD_ill_041_i7---IDT_i5_3.CABO_102_16S_I1.fastq"
## [298] "MI.M05812_0306.001.FLD_ill_041_i7---IDT_i5_3.CABO_102_16S_I2.fastq"
## [299] "MI.M05812_0306.001.FLD_ill_041_i7---IDT_i5_3.CABO_102_16S_R1.fastq"
## [300] "MI.M05812_0306.001.FLD_ill_041_i7---IDT_i5_3.CABO_102_16S_R2.fastq"
## [301] "MI.M05812_0306.001.FLD_ill_041_i7---IDT_i5_4.CABO_186_16S_I1.fastq"
## [302] "MI.M05812_0306.001.FLD_ill_041_i7---IDT_i5_4.CABO_186_16S_I2.fastq"
## [303] "MI.M05812_0306.001.FLD_ill_041_i7---IDT_i5_4.CABO_186_16S_R1.fastq"
## [304] "MI.M05812_0306.001.FLD_ill_041_i7---IDT_i5_4.CABO_186_16S_R2.fastq"
## [305] "MI.M05812_0306.001.FLD_ill_042_i7---IDT_i5_3.CABO_114_16S_I1.fastq"
## [306] "MI.M05812_0306.001.FLD_ill_042_i7---IDT_i5_3.CABO_114_16S_I2.fastq"
## [307] "MI.M05812_0306.001.FLD_ill_042_i7---IDT_i5_3.CABO_114_16S_R1.fastq"
## [308] "MI.M05812_0306.001.FLD_ill_042_i7---IDT_i5_3.CABO_114_16S_R2.fastq"
## [309] "MI.M05812_0306.001.FLD_ill_043_i7---IDT_i5_2.CABO_030_16S_I1.fastq"
## [310] "MI.M05812_0306.001.FLD_ill_043_i7---IDT_i5_2.CABO_030_16S_I2.fastq"
## [311] "MI.M05812_0306.001.FLD_ill_043_i7---IDT_i5_2.CABO_030_16S_R1.fastq"
## [312] "MI.M05812_0306.001.FLD_ill_043_i7---IDT_i5_2.CABO_030_16S_R2.fastq"
## [313] "MI.M05812_0306.001.FLD_ill_043_i7---IDT_i5_3.CABO_126_16S_I1.fastq"
## [314] "MI.M05812_0306.001.FLD_ill_043_i7---IDT_i5_3.CABO_126_16S_I2.fastq"
## [315] "MI.M05812_0306.001.FLD_ill_043_i7---IDT_i5_3.CABO_126_16S_R1.fastq"
## [316] "MI.M05812_0306.001.FLD_ill_043_i7---IDT_i5_3.CABO_126_16S_R2.fastq"
## [317] "MI.M05812_0306.001.FLD_ill_049_i7---IDT_i5_3.CABO_007_16S_I1.fastq"
## [318] "MI.M05812_0306.001.FLD_ill_049_i7---IDT_i5_3.CABO_007_16S_I2.fastq"
## [319] "MI.M05812_0306.001.FLD_ill_049_i7---IDT_i5_3.CABO_007_16S_R1.fastq"
## [320] "MI.M05812_0306.001.FLD_ill_049_i7---IDT_i5_3.CABO_007_16S_R2.fastq"
## [321] "MI.M05812_0306.001.FLD_ill_049_i7---IDT_i5_4.CABO_103_16S_I1.fastq"
## [322] "MI.M05812_0306.001.FLD_ill_049_i7---IDT_i5_4.CABO_103_16S_I2.fastq"
## [323] "MI.M05812_0306.001.FLD_ill_049_i7---IDT_i5_4.CABO_103_16S_R1.fastq"
## [324] "MI.M05812_0306.001.FLD_ill_049_i7---IDT_i5_4.CABO_103_16S_R2.fastq"
## [325] "MI.M05812_0306.001.FLD_ill_050_i7---IDT_i5_4.CABO_115_16S_I1.fastq"
## [326] "MI.M05812_0306.001.FLD_ill_050_i7---IDT_i5_4.CABO_115_16S_I2.fastq"
## [327] "MI.M05812_0306.001.FLD_ill_050_i7---IDT_i5_4.CABO_115_16S_R1.fastq"
## [328] "MI.M05812_0306.001.FLD_ill_050_i7---IDT_i5_4.CABO_115_16S_R2.fastq"
## [329] "MI.M05812_0306.001.FLD_ill_051_i7---IDT_i5_3.CABO_031_16S_I1.fastq"
## [330] "MI.M05812_0306.001.FLD_ill_051_i7---IDT_i5_3.CABO_031_16S_I2.fastq"
## [331] "MI.M05812_0306.001.FLD_ill_051_i7---IDT_i5_3.CABO_031_16S_R1.fastq"
## [332] "MI.M05812_0306.001.FLD_ill_051_i7---IDT_i5_3.CABO_031_16S_R2.fastq"
## [333] "MI.M05812_0306.001.FLD_ill_051_i7---IDT_i5_4.CABO_127_16S_I1.fastq"
## [334] "MI.M05812_0306.001.FLD_ill_051_i7---IDT_i5_4.CABO_127_16S_I2.fastq"
## [335] "MI.M05812_0306.001.FLD_ill_051_i7---IDT_i5_4.CABO_127_16S_R1.fastq"
## [336] "MI.M05812_0306.001.FLD_ill_051_i7---IDT_i5_4.CABO_127_16S_R2.fastq"
## [337] "MI.M05812_0306.001.FLD_ill_056_i7---IDT_i5_3.CABO_091_16S_I1.fastq"
## [338] "MI.M05812_0306.001.FLD_ill_056_i7---IDT_i5_3.CABO_091_16S_I2.fastq"
## [339] "MI.M05812_0306.001.FLD_ill_056_i7---IDT_i5_3.CABO_091_16S_R1.fastq"
## [340] "MI.M05812_0306.001.FLD_ill_056_i7---IDT_i5_3.CABO_091_16S_R2.fastq"
## [341] "MI.M05812_0306.001.FLD_ill_057_i7---IDT_i5_4.CABO_008_16S_I1.fastq"
## [342] "MI.M05812_0306.001.FLD_ill_057_i7---IDT_i5_4.CABO_008_16S_I2.fastq"
## [343] "MI.M05812_0306.001.FLD_ill_057_i7---IDT_i5_4.CABO_008_16S_R1.fastq"
## [344] "MI.M05812_0306.001.FLD_ill_057_i7---IDT_i5_4.CABO_008_16S_R2.fastq"
## [345] "MI.M05812_0306.001.FLD_ill_057_i7---IDT_i5_5.CABO_104_16S_I1.fastq"
## [346] "MI.M05812_0306.001.FLD_ill_057_i7---IDT_i5_5.CABO_104_16S_I2.fastq"
## [347] "MI.M05812_0306.001.FLD_ill_057_i7---IDT_i5_5.CABO_104_16S_R1.fastq"
## [348] "MI.M05812_0306.001.FLD_ill_057_i7---IDT_i5_5.CABO_104_16S_R2.fastq"
## [349] "MI.M05812_0306.001.FLD_ill_057_i7---IDT_i5_6.CABO_193_16S_I1.fastq"
## [350] "MI.M05812_0306.001.FLD_ill_057_i7---IDT_i5_6.CABO_193_16S_I2.fastq"
## [351] "MI.M05812_0306.001.FLD_ill_057_i7---IDT_i5_6.CABO_193_16S_R1.fastq"
## [352] "MI.M05812_0306.001.FLD_ill_057_i7---IDT_i5_6.CABO_193_16S_R2.fastq"
## [353] "MI.M05812_0306.001.FLD_ill_058_i7---IDT_i5_5.CABO_116_16S_I1.fastq"
## [354] "MI.M05812_0306.001.FLD_ill_058_i7---IDT_i5_5.CABO_116_16S_I2.fastq"
## [355] "MI.M05812_0306.001.FLD_ill_058_i7---IDT_i5_5.CABO_116_16S_R1.fastq"
## [356] "MI.M05812_0306.001.FLD_ill_058_i7---IDT_i5_5.CABO_116_16S_R2.fastq"
## [357] "MI.M05812_0306.001.FLD_ill_059_i7---IDT_i5_4.CABO_032_16S_I1.fastq"
## [358] "MI.M05812_0306.001.FLD_ill_059_i7---IDT_i5_4.CABO_032_16S_I2.fastq"
## [359] "MI.M05812_0306.001.FLD_ill_059_i7---IDT_i5_4.CABO_032_16S_R1.fastq"
## [360] "MI.M05812_0306.001.FLD_ill_059_i7---IDT_i5_4.CABO_032_16S_R2.fastq"
## [361] "MI.M05812_0306.001.FLD_ill_059_i7---IDT_i5_5.CABO_128_16S_I1.fastq"
## [362] "MI.M05812_0306.001.FLD_ill_059_i7---IDT_i5_5.CABO_128_16S_I2.fastq"
## [363] "MI.M05812_0306.001.FLD_ill_059_i7---IDT_i5_5.CABO_128_16S_R1.fastq"
## [364] "MI.M05812_0306.001.FLD_ill_059_i7---IDT_i5_5.CABO_128_16S_R2.fastq"
## [365] "MI.M05812_0306.001.FLD_ill_065_i7---IDT_i5_5.CABO_009_16S_I1.fastq"
## [366] "MI.M05812_0306.001.FLD_ill_065_i7---IDT_i5_5.CABO_009_16S_I2.fastq"
## [367] "MI.M05812_0306.001.FLD_ill_065_i7---IDT_i5_5.CABO_009_16S_R1.fastq"
## [368] "MI.M05812_0306.001.FLD_ill_065_i7---IDT_i5_5.CABO_009_16S_R2.fastq"
## [369] "MI.M05812_0306.001.FLD_ill_065_i7---IDT_i5_6.CABO_105_16S_I1.fastq"
## [370] "MI.M05812_0306.001.FLD_ill_065_i7---IDT_i5_6.CABO_105_16S_I2.fastq"
## [371] "MI.M05812_0306.001.FLD_ill_065_i7---IDT_i5_6.CABO_105_16S_R1.fastq"
## [372] "MI.M05812_0306.001.FLD_ill_065_i7---IDT_i5_6.CABO_105_16S_R2.fastq"
## [373] "MI.M05812_0306.001.FLD_ill_065_i7---IDT_i5_7.CABO_194_16S_I1.fastq"
## [374] "MI.M05812_0306.001.FLD_ill_065_i7---IDT_i5_7.CABO_194_16S_I2.fastq"
## [375] "MI.M05812_0306.001.FLD_ill_065_i7---IDT_i5_7.CABO_194_16S_R1.fastq"
## [376] "MI.M05812_0306.001.FLD_ill_065_i7---IDT_i5_7.CABO_194_16S_R2.fastq"
## [377] "MI.M05812_0306.001.FLD_ill_066_i7---IDT_i5_5.CABO_021_16S_I1.fastq"
## [378] "MI.M05812_0306.001.FLD_ill_066_i7---IDT_i5_5.CABO_021_16S_I2.fastq"
## [379] "MI.M05812_0306.001.FLD_ill_066_i7---IDT_i5_5.CABO_021_16S_R1.fastq"
## [380] "MI.M05812_0306.001.FLD_ill_066_i7---IDT_i5_5.CABO_021_16S_R2.fastq"
## [381] "MI.M05812_0306.001.FLD_ill_066_i7---IDT_i5_6.CABO_117_16S_I1.fastq"
## [382] "MI.M05812_0306.001.FLD_ill_066_i7---IDT_i5_6.CABO_117_16S_I2.fastq"
## [383] "MI.M05812_0306.001.FLD_ill_066_i7---IDT_i5_6.CABO_117_16S_R1.fastq"
## [384] "MI.M05812_0306.001.FLD_ill_066_i7---IDT_i5_6.CABO_117_16S_R2.fastq"
## [385] "MI.M05812_0306.001.FLD_ill_067_i7---IDT_i5_5.CABO_033_16S_I1.fastq"
## [386] "MI.M05812_0306.001.FLD_ill_067_i7---IDT_i5_5.CABO_033_16S_I2.fastq"
## [387] "MI.M05812_0306.001.FLD_ill_067_i7---IDT_i5_5.CABO_033_16S_R1.fastq"
## [388] "MI.M05812_0306.001.FLD_ill_067_i7---IDT_i5_5.CABO_033_16S_R2.fastq"
## [389] "MI.M05812_0306.001.FLD_ill_067_i7---IDT_i5_6.CABO_129_16S_I1.fastq"
## [390] "MI.M05812_0306.001.FLD_ill_067_i7---IDT_i5_6.CABO_129_16S_I2.fastq"
## [391] "MI.M05812_0306.001.FLD_ill_067_i7---IDT_i5_6.CABO_129_16S_R1.fastq"
## [392] "MI.M05812_0306.001.FLD_ill_067_i7---IDT_i5_6.CABO_129_16S_R2.fastq"
## [393] "MI.M05812_0306.001.FLD_ill_068_i7---IDT_i5_6.CABO_141_16S_I1.fastq"
## [394] "MI.M05812_0306.001.FLD_ill_068_i7---IDT_i5_6.CABO_141_16S_I2.fastq"
## [395] "MI.M05812_0306.001.FLD_ill_068_i7---IDT_i5_6.CABO_141_16S_R1.fastq"
## [396] "MI.M05812_0306.001.FLD_ill_068_i7---IDT_i5_6.CABO_141_16S_R2.fastq"
## [397] "MI.M05812_0306.001.FLD_ill_073_i7---IDT_i5_6.CABO_010_16S_I1.fastq"
## [398] "MI.M05812_0306.001.FLD_ill_073_i7---IDT_i5_6.CABO_010_16S_I2.fastq"
## [399] "MI.M05812_0306.001.FLD_ill_073_i7---IDT_i5_6.CABO_010_16S_R1.fastq"
## [400] "MI.M05812_0306.001.FLD_ill_073_i7---IDT_i5_6.CABO_010_16S_R2.fastq"
## [401] "MI.M05812_0306.001.FLD_ill_073_i7---IDT_i5_8.CABO_195_16S_I1.fastq"
## [402] "MI.M05812_0306.001.FLD_ill_073_i7---IDT_i5_8.CABO_195_16S_I2.fastq"
## [403] "MI.M05812_0306.001.FLD_ill_073_i7---IDT_i5_8.CABO_195_16S_R1.fastq"
## [404] "MI.M05812_0306.001.FLD_ill_073_i7---IDT_i5_8.CABO_195_16S_R2.fastq"
## [405] "MI.M05812_0306.001.FLD_ill_074_i7---IDT_i5_6.CABO_022_16S_I1.fastq"
## [406] "MI.M05812_0306.001.FLD_ill_074_i7---IDT_i5_6.CABO_022_16S_I2.fastq"
## [407] "MI.M05812_0306.001.FLD_ill_074_i7---IDT_i5_6.CABO_022_16S_R1.fastq"
## [408] "MI.M05812_0306.001.FLD_ill_074_i7---IDT_i5_6.CABO_022_16S_R2.fastq"
## [409] "MI.M05812_0306.001.FLD_ill_074_i7---IDT_i5_7.CABO_118_16S_I1.fastq"
## [410] "MI.M05812_0306.001.FLD_ill_074_i7---IDT_i5_7.CABO_118_16S_I2.fastq"
## [411] "MI.M05812_0306.001.FLD_ill_074_i7---IDT_i5_7.CABO_118_16S_R1.fastq"
## [412] "MI.M05812_0306.001.FLD_ill_074_i7---IDT_i5_7.CABO_118_16S_R2.fastq"
## [413] "MI.M05812_0306.001.FLD_ill_075_i7---IDT_i5_6.CABO_034_16S_I1.fastq"
## [414] "MI.M05812_0306.001.FLD_ill_075_i7---IDT_i5_6.CABO_034_16S_I2.fastq"
## [415] "MI.M05812_0306.001.FLD_ill_075_i7---IDT_i5_6.CABO_034_16S_R1.fastq"
## [416] "MI.M05812_0306.001.FLD_ill_075_i7---IDT_i5_6.CABO_034_16S_R2.fastq"
## [417] "MI.M05812_0306.001.FLD_ill_075_i7---IDT_i5_7.CABO_130_16S_I1.fastq"
## [418] "MI.M05812_0306.001.FLD_ill_075_i7---IDT_i5_7.CABO_130_16S_I2.fastq"
## [419] "MI.M05812_0306.001.FLD_ill_075_i7---IDT_i5_7.CABO_130_16S_R1.fastq"
## [420] "MI.M05812_0306.001.FLD_ill_075_i7---IDT_i5_7.CABO_130_16S_R2.fastq"
## [421] "MI.M05812_0306.001.FLD_ill_076_i7---IDT_i5_7.CABO_142_16S_I1.fastq"
## [422] "MI.M05812_0306.001.FLD_ill_076_i7---IDT_i5_7.CABO_142_16S_I2.fastq"
## [423] "MI.M05812_0306.001.FLD_ill_076_i7---IDT_i5_7.CABO_142_16S_R1.fastq"
## [424] "MI.M05812_0306.001.FLD_ill_076_i7---IDT_i5_7.CABO_142_16S_R2.fastq"
## [425] "MI.M05812_0306.001.FLD_ill_081_i7---IDT_i5_7.CABO_011_16S_I1.fastq"
## [426] "MI.M05812_0306.001.FLD_ill_081_i7---IDT_i5_7.CABO_011_16S_I2.fastq"
## [427] "MI.M05812_0306.001.FLD_ill_081_i7---IDT_i5_7.CABO_011_16S_R1.fastq"
## [428] "MI.M05812_0306.001.FLD_ill_081_i7---IDT_i5_7.CABO_011_16S_R2.fastq"
## [429] "MI.M05812_0306.001.FLD_ill_081_i7---IDT_i5_8.CABO_107_16S_I1.fastq"
## [430] "MI.M05812_0306.001.FLD_ill_081_i7---IDT_i5_8.CABO_107_16S_I2.fastq"
## [431] "MI.M05812_0306.001.FLD_ill_081_i7---IDT_i5_8.CABO_107_16S_R1.fastq"
## [432] "MI.M05812_0306.001.FLD_ill_081_i7---IDT_i5_8.CABO_107_16S_R2.fastq"
## [433] "MI.M05812_0306.001.FLD_ill_081_i7---IDT_i5_9.CABO_198_16S_I1.fastq"
## [434] "MI.M05812_0306.001.FLD_ill_081_i7---IDT_i5_9.CABO_198_16S_I2.fastq"
## [435] "MI.M05812_0306.001.FLD_ill_081_i7---IDT_i5_9.CABO_198_16S_R1.fastq"
## [436] "MI.M05812_0306.001.FLD_ill_081_i7---IDT_i5_9.CABO_198_16S_R2.fastq"
## [437] "MI.M05812_0306.001.FLD_ill_082_i7---IDT_i5_7.CABO_023_16S_I1.fastq"
## [438] "MI.M05812_0306.001.FLD_ill_082_i7---IDT_i5_7.CABO_023_16S_I2.fastq"
## [439] "MI.M05812_0306.001.FLD_ill_082_i7---IDT_i5_7.CABO_023_16S_R1.fastq"
## [440] "MI.M05812_0306.001.FLD_ill_082_i7---IDT_i5_7.CABO_023_16S_R2.fastq"
## [441] "MI.M05812_0306.001.FLD_ill_082_i7---IDT_i5_8.CABO_119_16S_I1.fastq"
## [442] "MI.M05812_0306.001.FLD_ill_082_i7---IDT_i5_8.CABO_119_16S_I2.fastq"
## [443] "MI.M05812_0306.001.FLD_ill_082_i7---IDT_i5_8.CABO_119_16S_R1.fastq"
## [444] "MI.M05812_0306.001.FLD_ill_082_i7---IDT_i5_8.CABO_119_16S_R2.fastq"
## [445] "MI.M05812_0306.001.FLD_ill_083_i7---IDT_i5_7.CABO_035_16S_I1.fastq"
## [446] "MI.M05812_0306.001.FLD_ill_083_i7---IDT_i5_7.CABO_035_16S_I2.fastq"
## [447] "MI.M05812_0306.001.FLD_ill_083_i7---IDT_i5_7.CABO_035_16S_R1.fastq"
## [448] "MI.M05812_0306.001.FLD_ill_083_i7---IDT_i5_7.CABO_035_16S_R2.fastq"
## [449] "MI.M05812_0306.001.FLD_ill_083_i7---IDT_i5_8.CABO_131_16S_I1.fastq"
## [450] "MI.M05812_0306.001.FLD_ill_083_i7---IDT_i5_8.CABO_131_16S_I2.fastq"
## [451] "MI.M05812_0306.001.FLD_ill_083_i7---IDT_i5_8.CABO_131_16S_R1.fastq"
## [452] "MI.M05812_0306.001.FLD_ill_083_i7---IDT_i5_8.CABO_131_16S_R2.fastq"
## [453] "MI.M05812_0306.001.FLD_ill_084_i7---IDT_i5_8.CABO_143_16S_I1.fastq"
## [454] "MI.M05812_0306.001.FLD_ill_084_i7---IDT_i5_8.CABO_143_16S_I2.fastq"
## [455] "MI.M05812_0306.001.FLD_ill_084_i7---IDT_i5_8.CABO_143_16S_R1.fastq"
## [456] "MI.M05812_0306.001.FLD_ill_084_i7---IDT_i5_8.CABO_143_16S_R2.fastq"
## [457] "MI.M05812_0306.001.FLD_ill_089_i7---IDT_i5_10.CABO_199_16S_I1.fastq"
## [458] "MI.M05812_0306.001.FLD_ill_089_i7---IDT_i5_10.CABO_199_16S_I2.fastq"
## [459] "MI.M05812_0306.001.FLD_ill_089_i7---IDT_i5_10.CABO_199_16S_R1.fastq"
## [460] "MI.M05812_0306.001.FLD_ill_089_i7---IDT_i5_10.CABO_199_16S_R2.fastq"
## [461] "MI.M05812_0306.001.FLD_ill_089_i7---IDT_i5_8.CABO_012_16S_I1.fastq"
## [462] "MI.M05812_0306.001.FLD_ill_089_i7---IDT_i5_8.CABO_012_16S_I2.fastq"
## [463] "MI.M05812_0306.001.FLD_ill_089_i7---IDT_i5_8.CABO_012_16S_R1.fastq"
## [464] "MI.M05812_0306.001.FLD_ill_089_i7---IDT_i5_8.CABO_012_16S_R2.fastq"
## [465] "MI.M05812_0306.001.FLD_ill_089_i7---IDT_i5_9.CABO_108_16S_I1.fastq"
## [466] "MI.M05812_0306.001.FLD_ill_089_i7---IDT_i5_9.CABO_108_16S_I2.fastq"
## [467] "MI.M05812_0306.001.FLD_ill_089_i7---IDT_i5_9.CABO_108_16S_R1.fastq"
## [468] "MI.M05812_0306.001.FLD_ill_089_i7---IDT_i5_9.CABO_108_16S_R2.fastq"
## [469] "MI.M05812_0306.001.FLD_ill_090_i7---IDT_i5_8.CABO_024_16S_I1.fastq"
## [470] "MI.M05812_0306.001.FLD_ill_090_i7---IDT_i5_8.CABO_024_16S_I2.fastq"
## [471] "MI.M05812_0306.001.FLD_ill_090_i7---IDT_i5_8.CABO_024_16S_R1.fastq"
## [472] "MI.M05812_0306.001.FLD_ill_090_i7---IDT_i5_8.CABO_024_16S_R2.fastq"
## [473] "MI.M05812_0306.001.FLD_ill_090_i7---IDT_i5_9.CABO_120_16S_I1.fastq"
## [474] "MI.M05812_0306.001.FLD_ill_090_i7---IDT_i5_9.CABO_120_16S_I2.fastq"
## [475] "MI.M05812_0306.001.FLD_ill_090_i7---IDT_i5_9.CABO_120_16S_R1.fastq"
## [476] "MI.M05812_0306.001.FLD_ill_090_i7---IDT_i5_9.CABO_120_16S_R2.fastq"
## [477] "MI.M05812_0306.001.FLD_ill_091_i7---IDT_i5_8.CABO_036_16S_I1.fastq"
## [478] "MI.M05812_0306.001.FLD_ill_091_i7---IDT_i5_8.CABO_036_16S_I2.fastq"
## [479] "MI.M05812_0306.001.FLD_ill_091_i7---IDT_i5_8.CABO_036_16S_R1.fastq"
## [480] "MI.M05812_0306.001.FLD_ill_091_i7---IDT_i5_8.CABO_036_16S_R2.fastq"
## [481] "MI.M05812_0306.001.FLD_ill_091_i7---IDT_i5_9.CABO_132_16S_I1.fastq"
## [482] "MI.M05812_0306.001.FLD_ill_091_i7---IDT_i5_9.CABO_132_16S_I2.fastq"
## [483] "MI.M05812_0306.001.FLD_ill_091_i7---IDT_i5_9.CABO_132_16S_R1.fastq"
## [484] "MI.M05812_0306.001.FLD_ill_091_i7---IDT_i5_9.CABO_132_16S_R2.fastq"
## [485] "MI.M05812_0306.001.FLD_ill_092_i7---IDT_i5_9.CABO_144_16S_I1.fastq"
## [486] "MI.M05812_0306.001.FLD_ill_092_i7---IDT_i5_9.CABO_144_16S_I2.fastq"
## [487] "MI.M05812_0306.001.FLD_ill_092_i7---IDT_i5_9.CABO_144_16S_R1.fastq"
## [488] "MI.M05812_0306.001.FLD_ill_092_i7---IDT_i5_9.CABO_144_16S_R2.fastq"
## [489] "MI.M05812_0306.001.FLD_ill_096_i7---IDT_i5_10.BlankpcrCES_I1.fastq"
## [490] "MI.M05812_0306.001.FLD_ill_096_i7---IDT_i5_10.BlankpcrCES_I2.fastq"
## [491] "MI.M05812_0306.001.FLD_ill_096_i7---IDT_i5_10.BlankpcrCES_R1.fastq"
## [492] "MI.M05812_0306.001.FLD_ill_096_i7---IDT_i5_10.BlankpcrCES_R2.fastq"
## [493] "multivar.disp.gdd.jpg"
## [494] "multivar.disp.spp.jpg"
## [495] "myplot_shannon.jpg"
## [496] "myplot_specnumber.jpg"
## [497] "myplot_specnumber2.jpg"
## [498] "niche_plots_combined.pdf"
## [499] "niche_plots_combined.png"
## [500] "niche_plots_combined.tif"
## [501] "niche_plots_combined.tiff"
## [502] "niche_proportions_total_asvs_filt.pdf"
## [503] "niche_proportions_total_asvs_filt.png"
## [504] "niche_proportions_total_asvs_filt.tiff"
## [505] "niche_violin_plot.pdf"
## [506] "niche_violin_plot.png"
## [507] "niche_violin_plot.tiff"
## [508] "NicheWidth_Table_Annotated.csv"
## [509] "pcoa.table_phenology_filtered.csv"
## [510] "pcoas_gdd_combined.png"
## [511] "phen_disper_gdd_boxplot.png"
## [512] "phen_disper_gdd_pcoa.png"
## [513] "phen_disper_spp_boxplot.png"
## [514] "phen_disper_spp_pcoa.png"
## [515] "Phenology_beta_nosize3.png"
## [516] "Phenology_beta_shannon_gdd.jpeg"
## [517] "phyloseq_df.csv"
## [518] "populus_comp_gdd_gen2.png"
## [519] "populus_composition_final.png"
## [520] "populus_composition_gdd_phyla2.png"
## [521] "populus_disper_gdd_boxplot.png"
## [522] "populus_disper_gdd_pcoa.png"
## [523] "populus_disper_plantid_boxplot.png"
## [524] "populus_disper_plantid_pcoa.png"
## [525] "populus_gen_composition_final.png"
## [526] "preston_lognormal.pdf"
## [527] "preston_lognormal.png"
## [528] "ps_df.csv"
## [529] "ps_sample_data.csv"
## [530] "ps2_phyla_df.csv"
## [531] "relabund_bet_gen2.csv"
## [532] "relabund_genus.csv"
## [533] "relabund_genus_combined.jpg"
## [534] "relabund_phyla.csv"
## [535] "relabund_phyla_combined.jpg"
## [536] "relabund_phyla_combined.png"
## [537] "relative_abundances.csv"
## [538] "RMarkdown_versions"
## [539] "Seq_renamed"
## [540] "seqtab.csv"
## [541] "seqtab.nochim.csv"
## [542] "seqtab.print.csv"
## [543] "Shannon_phenology_16S.jpeg"
## [544] "specaccum_positive_control.jpg"
## [545] "specaccum_samples.jpg"
## [546] "statplot1_combined.jpg"
## [547] "taxa"
## [548] "taxa_scaled_phyla.csv"
## [549] "taxaMat.csv"
## [550] "tmp_render.R"
## [551] "top_asv_table.csv"
## [552] "top_asv_table.txt"
## [553] "top_asv_table_bet_cont_gdd_trend.csv"
## [554] "top_asv_table_bet_cont_gdd_trend.txt"
## [555] "top_asv_table_interaction.csv"
## [556] "top_asv_table_interaction.txt"
## [557] "top_asv_table_LMM.csv"
## [558] "top_asv_table_LMM.txt"
## [559] "top_asv_table_LMM_1087.csv"
## [560] "top_asv_table_LMM_1606.csv"
## [561] "top_asv_table_LMM_1992.csv"
## [562] "top_asv_table_LMM_2140.csv"
## [563] "top_asv_table_LMM_2219.csv"
## [564] "top_asv_table_LMM_437.csv"
## [565] "top_asv_table_LMM_605.csv"
## [566] "top_asv_table_pop_cont_gdd_trend.csv"
## [567] "top_asv_table_top_asv_table_pop_cont_gdd_trend.txt"
## [568] "tx.csv"
## [569] "unified_legend.pdf"
## [570] "unified_legend.png"
########################################################################################### Read
########################################################################################### in
########################################################################################### the
########################################################################################### names
########################################################################################### of
########################################################################################### the
########################################################################################### fastq
########################################################################################### files,
########################################################################################### and
########################################################################################### perform
########################################################################################### some
########################################################################################### string
########################################################################################### manipulation
########################################################################################### to
########################################################################################### get
########################################################################################### matched
########################################################################################### lists
########################################################################################### of
########################################################################################### the
########################################################################################### forward
########################################################################################### and
########################################################################################### reverse
########################################################################################### fastq
########################################################################################### files:
# Forward and reverse fastq filenames have format: SAMPLENAME_R1.fastq and
# SAMPLENAME_R2.fastq
fnFs <- sort(list.files(path, pattern = "_R1.fastq", full.names = TRUE))
fnRs <- sort(list.files(path, pattern = "_R2.fastq", full.names = TRUE))
################################################################################ Extract
################################################################################ sample
################################################################################ names:
sample.names <- sapply(strsplit(basename(fnFs), "[.]"), `[`, 5)
################################################################################ INSPECT
################################################################################ READ
################################################################################ QUALITY
################################################################################ PROFILES:
# Start by visualizing the quality profiles of the forward reads:
plotQualityProfile(fnFs[1:2])
# Now visualize the quality profile of the reverse reads:
plotQualityProfile(fnRs[1:2])
################################################################################ FILTER
################################################################################ &
################################################################################ TRIM:
# Assign the filenames for the filtered fastq files. Place filtered files in
# filtered/ subdirectory
filtFs <- file.path(path, "filtered", paste0(sample.names, "_F_filt.fastq"))
filtRs <- file.path(path, "filtered", paste0(sample.names, "_R_filt.fastq"))
# I use standard filtering parameters: maxN=0 (DADA2 requires no Ns), truncQ=2,
# rm.phix=TRUE and maxEE=2. The maxEE parameter sets the maximum number of
# “expected errors” allowed in a read, which is a better filter than simply
# averaging quality scores. We want at least 70-80% of the reads reads out
# (e.g., for CABO_109_16S_R1.fastq: 49955/55692 = 0.9, great recovery).
# NOTE: Did not need to remove primers in this dataset b/c of NGS being so good
# at QC and whatnot, as Itumeleng explained, but if we did want to, we would
# do: 'In the standard 16S workflow, it is generally possible to remove primers
# (when included on the reads) via the trimLeft parameter (filterAndTrim(...,
# trimLeft=(FWD_PRIMER_LEN, REV_PRIMER_LEN)))'
out <- filterAndTrim(fnFs, filtFs, fnRs, filtRs, truncLen = c(240, 230), maxN = 0,
maxEE = c(2, 2), truncQ = 2, rm.phix = TRUE, compress = TRUE, multithread = FALSE) # On Windows set multithread=FALSE
head(out)
## reads.in
## MI.M05812_0306.001.FLD_ill_002_i7---IDT_i5_10.CABO_109_16S_R1.fastq 55692
## MI.M05812_0306.001.FLD_ill_003_i7---IDT_i5_10.CABO_121_16S_R1.fastq 54309
## MI.M05812_0306.001.FLD_ill_003_i7---IDT_i5_9.CABO_025_16S_R1.fastq 56613
## MI.M05812_0306.001.FLD_ill_004_i7---IDT_i5_9.CABO_037_16S_R1.fastq 54473
## MI.M05812_0306.001.FLD_ill_005_i7---IDT_i5_10.CABO_145_16S_R1.fastq 46982
## MI.M05812_0306.001.FLD_ill_009_i7---IDT_i5_10.CABO_002_16S_R1.fastq 55213
## reads.out
## MI.M05812_0306.001.FLD_ill_002_i7---IDT_i5_10.CABO_109_16S_R1.fastq 49955
## MI.M05812_0306.001.FLD_ill_003_i7---IDT_i5_10.CABO_121_16S_R1.fastq 48508
## MI.M05812_0306.001.FLD_ill_003_i7---IDT_i5_9.CABO_025_16S_R1.fastq 51025
## MI.M05812_0306.001.FLD_ill_004_i7---IDT_i5_9.CABO_037_16S_R1.fastq 48613
## MI.M05812_0306.001.FLD_ill_005_i7---IDT_i5_10.CABO_145_16S_R1.fastq 42505
## MI.M05812_0306.001.FLD_ill_009_i7---IDT_i5_10.CABO_002_16S_R1.fastq 47658
################################################################################ LEARNING
################################################################################ ERROR
################################################################################ RATES
# The DADA2 algorithm makes use of a parametric error model (err) and every
# amplicon dataset has a different set of error rates. The learnErrors method
# learns this error model from the data, by alternating estimation of the error
# rates and inference of sample composition until they converge on a jointly
# consistent solution. As in many machine-learning problems, the algorithm must
# begin with an initial guess, for which the maximum possible error rates in
# this data are used (the error rates if only the most abundant sequence is
# correct and all the rest are errors).
errF <- learnErrors(filtFs, multithread = TRUE)
## 103528080 total bases in 431367 reads from 9 samples will be used for learning the error rates.
errR <- learnErrors(filtRs, multithread = TRUE)
## 107750400 total bases in 468480 reads from 10 samples will be used for learning the error rates.
################################################################################ PLOT
################################################################################ &
################################################################################ VISUALIZE
################################################################################ ESTIMATED
################################################################################ ERROR
################################################################################ RATES
################################################################################ (Sanity
################################################################################ Check):
plotErrors(errF, nominalQ = TRUE)
# The error rates for each possible transition (A→C, A→G, …) are shown. Points
# are the observed error rates for each consensus quality score. The black
# line shows the estimated error rates after convergence of the
# machine-learning algorithm. The red line shows the error rates expected
# under the nominal definition of the Q-score.
# Here the estimated error rates (black line) are a good fit to the observed
# rates (points), and the error rates drop with increased quality as expected.
# Everything looks reasonable and we proceed with confidence.
################################################################################ SAMPLE
################################################################################ INFERENCE
# Now apply the core sample inference algorithm to the dereplicated data:
dadaFs <- dada(filtFs, err = errF, multithread = FALSE)
## Sample 1 - 49955 reads in 2518 unique sequences.
## Sample 2 - 48508 reads in 2475 unique sequences.
## Sample 3 - 51025 reads in 3352 unique sequences.
## Sample 4 - 48613 reads in 2690 unique sequences.
## Sample 5 - 42505 reads in 2083 unique sequences.
## Sample 6 - 47658 reads in 3949 unique sequences.
## Sample 7 - 45048 reads in 2496 unique sequences.
## Sample 8 - 56612 reads in 2555 unique sequences.
## Sample 9 - 41443 reads in 2225 unique sequences.
## Sample 10 - 37113 reads in 2178 unique sequences.
## Sample 11 - 46610 reads in 2457 unique sequences.
## Sample 12 - 38523 reads in 2102 unique sequences.
## Sample 13 - 53322 reads in 3230 unique sequences.
## Sample 14 - 48345 reads in 2362 unique sequences.
## Sample 15 - 36795 reads in 1988 unique sequences.
## Sample 16 - 42767 reads in 2264 unique sequences.
## Sample 17 - 47674 reads in 2353 unique sequences.
## Sample 18 - 36908 reads in 3224 unique sequences.
## Sample 19 - 47826 reads in 2813 unique sequences.
## Sample 20 - 45643 reads in 3567 unique sequences.
## Sample 21 - 45180 reads in 2361 unique sequences.
## Sample 22 - 43678 reads in 2222 unique sequences.
## Sample 23 - 41995 reads in 2235 unique sequences.
## Sample 24 - 36425 reads in 3530 unique sequences.
## Sample 25 - 54541 reads in 2888 unique sequences.
## Sample 26 - 30792 reads in 2002 unique sequences.
## Sample 27 - 44874 reads in 3316 unique sequences.
## Sample 28 - 39564 reads in 2197 unique sequences.
## Sample 29 - 42988 reads in 2567 unique sequences.
## Sample 30 - 38078 reads in 2377 unique sequences.
## Sample 31 - 38727 reads in 4183 unique sequences.
## Sample 32 - 43921 reads in 2264 unique sequences.
## Sample 33 - 43153 reads in 2396 unique sequences.
## Sample 34 - 44553 reads in 2621 unique sequences.
## Sample 35 - 41204 reads in 2337 unique sequences.
## Sample 36 - 54187 reads in 2389 unique sequences.
## Sample 37 - 46619 reads in 2482 unique sequences.
## Sample 38 - 32488 reads in 1898 unique sequences.
## Sample 39 - 38895 reads in 2140 unique sequences.
## Sample 40 - 38374 reads in 2041 unique sequences.
## Sample 41 - 40612 reads in 4894 unique sequences.
## Sample 42 - 53416 reads in 2699 unique sequences.
## Sample 43 - 1392 reads in 368 unique sequences.
## Sample 44 - 42215 reads in 2887 unique sequences.
## Sample 45 - 41257 reads in 2364 unique sequences.
## Sample 46 - 51381 reads in 3115 unique sequences.
## Sample 47 - 42350 reads in 2311 unique sequences.
## Sample 48 - 42818 reads in 3253 unique sequences.
## Sample 49 - 23937 reads in 7279 unique sequences.
## Sample 50 - 36740 reads in 2214 unique sequences.
## Sample 51 - 31601 reads in 1960 unique sequences.
## Sample 52 - 36592 reads in 2167 unique sequences.
## Sample 53 - 41349 reads in 2259 unique sequences.
## Sample 54 - 39422 reads in 3681 unique sequences.
## Sample 55 - 43642 reads in 3295 unique sequences.
## Sample 56 - 39963 reads in 10421 unique sequences.
## Sample 57 - 40117 reads in 2120 unique sequences.
## Sample 58 - 52811 reads in 2536 unique sequences.
## Sample 59 - 35598 reads in 2474 unique sequences.
## Sample 60 - 44532 reads in 2691 unique sequences.
## Sample 61 - 49005 reads in 3017 unique sequences.
## Sample 62 - 56779 reads in 5008 unique sequences.
## Sample 63 - 47233 reads in 2463 unique sequences.
## Sample 64 - 642 reads in 140 unique sequences.
## Sample 65 - 50920 reads in 2641 unique sequences.
## Sample 66 - 41833 reads in 2769 unique sequences.
## Sample 67 - 38506 reads in 2059 unique sequences.
## Sample 68 - 44321 reads in 2302 unique sequences.
## Sample 69 - 43671 reads in 3430 unique sequences.
## Sample 70 - 890 reads in 205 unique sequences.
## Sample 71 - 48501 reads in 2505 unique sequences.
## Sample 72 - 54660 reads in 2707 unique sequences.
## Sample 73 - 37124 reads in 2374 unique sequences.
## Sample 74 - 59176 reads in 3563 unique sequences.
## Sample 75 - 41857 reads in 2201 unique sequences.
## Sample 76 - 56287 reads in 2794 unique sequences.
## Sample 77 - 41237 reads in 3725 unique sequences.
## Sample 78 - 255 reads in 85 unique sequences.
dadaRs <- dada(filtRs, err = errR, multithread = FALSE)
## Sample 1 - 49955 reads in 2666 unique sequences.
## Sample 2 - 48508 reads in 2591 unique sequences.
## Sample 3 - 51025 reads in 3492 unique sequences.
## Sample 4 - 48613 reads in 2811 unique sequences.
## Sample 5 - 42505 reads in 2342 unique sequences.
## Sample 6 - 47658 reads in 3854 unique sequences.
## Sample 7 - 45048 reads in 2708 unique sequences.
## Sample 8 - 56612 reads in 2845 unique sequences.
## Sample 9 - 41443 reads in 2518 unique sequences.
## Sample 10 - 37113 reads in 2269 unique sequences.
## Sample 11 - 46610 reads in 3006 unique sequences.
## Sample 12 - 38523 reads in 2266 unique sequences.
## Sample 13 - 53322 reads in 3362 unique sequences.
## Sample 14 - 48345 reads in 2413 unique sequences.
## Sample 15 - 36795 reads in 2082 unique sequences.
## Sample 16 - 42767 reads in 2477 unique sequences.
## Sample 17 - 47674 reads in 2769 unique sequences.
## Sample 18 - 36908 reads in 3505 unique sequences.
## Sample 19 - 47826 reads in 2840 unique sequences.
## Sample 20 - 45643 reads in 3700 unique sequences.
## Sample 21 - 45180 reads in 2488 unique sequences.
## Sample 22 - 43678 reads in 2268 unique sequences.
## Sample 23 - 41995 reads in 2696 unique sequences.
## Sample 24 - 36425 reads in 4396 unique sequences.
## Sample 25 - 54541 reads in 3207 unique sequences.
## Sample 26 - 30792 reads in 2081 unique sequences.
## Sample 27 - 44874 reads in 3572 unique sequences.
## Sample 28 - 39564 reads in 3414 unique sequences.
## Sample 29 - 42988 reads in 4073 unique sequences.
## Sample 30 - 38078 reads in 2498 unique sequences.
## Sample 31 - 38727 reads in 4380 unique sequences.
## Sample 32 - 43921 reads in 2417 unique sequences.
## Sample 33 - 43153 reads in 2638 unique sequences.
## Sample 34 - 44553 reads in 3097 unique sequences.
## Sample 35 - 41204 reads in 2644 unique sequences.
## Sample 36 - 54187 reads in 2889 unique sequences.
## Sample 37 - 46619 reads in 2561 unique sequences.
## Sample 38 - 32488 reads in 2154 unique sequences.
## Sample 39 - 38895 reads in 2506 unique sequences.
## Sample 40 - 38374 reads in 2496 unique sequences.
## Sample 41 - 40612 reads in 5063 unique sequences.
## Sample 42 - 53416 reads in 2987 unique sequences.
## Sample 43 - 1392 reads in 320 unique sequences.
## Sample 44 - 42215 reads in 3073 unique sequences.
## Sample 45 - 41257 reads in 2413 unique sequences.
## Sample 46 - 51381 reads in 3178 unique sequences.
## Sample 47 - 42350 reads in 3587 unique sequences.
## Sample 48 - 42818 reads in 5467 unique sequences.
## Sample 49 - 23937 reads in 7082 unique sequences.
## Sample 50 - 36740 reads in 2624 unique sequences.
## Sample 51 - 31601 reads in 2714 unique sequences.
## Sample 52 - 36592 reads in 2295 unique sequences.
## Sample 53 - 41349 reads in 2729 unique sequences.
## Sample 54 - 39422 reads in 4780 unique sequences.
## Sample 55 - 43642 reads in 3793 unique sequences.
## Sample 56 - 39963 reads in 9316 unique sequences.
## Sample 57 - 40117 reads in 2683 unique sequences.
## Sample 58 - 52811 reads in 2740 unique sequences.
## Sample 59 - 35598 reads in 2865 unique sequences.
## Sample 60 - 44532 reads in 2664 unique sequences.
## Sample 61 - 49005 reads in 3303 unique sequences.
## Sample 62 - 56779 reads in 4820 unique sequences.
## Sample 63 - 47233 reads in 2802 unique sequences.
## Sample 64 - 642 reads in 166 unique sequences.
## Sample 65 - 50920 reads in 2544 unique sequences.
## Sample 66 - 41833 reads in 2921 unique sequences.
## Sample 67 - 38506 reads in 2250 unique sequences.
## Sample 68 - 44321 reads in 2628 unique sequences.
## Sample 69 - 43671 reads in 3890 unique sequences.
## Sample 70 - 890 reads in 208 unique sequences.
## Sample 71 - 48501 reads in 3299 unique sequences.
## Sample 72 - 54660 reads in 2898 unique sequences.
## Sample 73 - 37124 reads in 2680 unique sequences.
## Sample 74 - 59176 reads in 3720 unique sequences.
## Sample 75 - 41857 reads in 2686 unique sequences.
## Sample 76 - 56287 reads in 3280 unique sequences.
## Sample 77 - 41237 reads in 4034 unique sequences.
## Sample 78 - 255 reads in 95 unique sequences.
# Inspecting the returned `dada-class` object:
dadaFs[[1]]
## dada-class: object describing DADA2 denoising results
## 47 sequence variants were inferred from 2518 input unique sequences.
## Key parameters: OMEGA_A = 1e-40, OMEGA_C = 1e-40, BAND_SIZE = 16
# The DADA2 algorithm inferred 47 true sequence variants from the 2518 unique
# sequences in the 2nd sample. There is much more to the `dada-class` return
# object than this (see help('dada-class') for some info), including multiple
# diagnostics about the quality of each denoised sequence variant (beyond the
# scope of introductory tutorial and my own knowledge right now).
# Means that out of 2518 starting unique sequences, only 47 were actual
# sequence variants (the other >2400 were just noise/errors likely, due to
# PCR).
################################################################################ MERGE
################################################################################ PAIRED
################################################################################ READS
# Now, merge the forward and reverse reads together to obtain the full denoised
# sequences. Merging is performed by aligning the denoised forward reads with
# the reverse-complement of the corresponding denoised reverse reads, and then
# constructing the merged “contig” sequences. By default, merged sequences are
# only output if the forward and reverse reads overlap by at least 12 bases,
# and are identical to each other in the overlap region.
mergers <- mergePairs(dadaFs, filtFs, dadaRs, filtRs, verbose = TRUE)
## 48038 paired-reads (in 50 unique pairings) successfully merged out of 49826 (in 70 pairings) input.
## 46838 paired-reads (in 40 unique pairings) successfully merged out of 48409 (in 49 pairings) input.
## 48966 paired-reads (in 93 unique pairings) successfully merged out of 50819 (in 130 pairings) input.
## 46774 paired-reads (in 70 unique pairings) successfully merged out of 48461 (in 86 pairings) input.
## 40913 paired-reads (in 45 unique pairings) successfully merged out of 42390 (in 64 pairings) input.
## 45889 paired-reads (in 144 unique pairings) successfully merged out of 47462 (in 184 pairings) input.
## 43092 paired-reads (in 91 unique pairings) successfully merged out of 44890 (in 137 pairings) input.
## 54449 paired-reads (in 53 unique pairings) successfully merged out of 56449 (in 88 pairings) input.
## 39877 paired-reads (in 61 unique pairings) successfully merged out of 41329 (in 75 pairings) input.
## 35673 paired-reads (in 57 unique pairings) successfully merged out of 36995 (in 76 pairings) input.
## 44970 paired-reads (in 33 unique pairings) successfully merged out of 46455 (in 43 pairings) input.
## 37039 paired-reads (in 40 unique pairings) successfully merged out of 38423 (in 53 pairings) input.
## 51344 paired-reads (in 132 unique pairings) successfully merged out of 53113 (in 176 pairings) input.
## 46504 paired-reads (in 74 unique pairings) successfully merged out of 48205 (in 95 pairings) input.
## 35507 paired-reads (in 39 unique pairings) successfully merged out of 36709 (in 53 pairings) input.
## 41215 paired-reads (in 64 unique pairings) successfully merged out of 42668 (in 80 pairings) input.
## 45631 paired-reads (in 69 unique pairings) successfully merged out of 47514 (in 93 pairings) input.
## 35522 paired-reads (in 85 unique pairings) successfully merged out of 36671 (in 143 pairings) input.
## 46009 paired-reads (in 47 unique pairings) successfully merged out of 47675 (in 67 pairings) input.
## 43999 paired-reads (in 127 unique pairings) successfully merged out of 45532 (in 155 pairings) input.
## 43475 paired-reads (in 53 unique pairings) successfully merged out of 45058 (in 79 pairings) input.
## 42102 paired-reads (in 46 unique pairings) successfully merged out of 43573 (in 62 pairings) input.
## 40430 paired-reads (in 53 unique pairings) successfully merged out of 41898 (in 74 pairings) input.
## 34903 paired-reads (in 108 unique pairings) successfully merged out of 36080 (in 243 pairings) input.
## 52682 paired-reads (in 55 unique pairings) successfully merged out of 54431 (in 76 pairings) input.
## 29723 paired-reads (in 26 unique pairings) successfully merged out of 30694 (in 37 pairings) input.
## 43190 paired-reads (in 134 unique pairings) successfully merged out of 44682 (in 188 pairings) input.
## 38142 paired-reads (in 52 unique pairings) successfully merged out of 39454 (in 69 pairings) input.
## 41401 paired-reads (in 55 unique pairings) successfully merged out of 42821 (in 81 pairings) input.
## 36585 paired-reads (in 78 unique pairings) successfully merged out of 37961 (in 97 pairings) input.
## 36929 paired-reads (in 142 unique pairings) successfully merged out of 38294 (in 272 pairings) input.
## 42276 paired-reads (in 59 unique pairings) successfully merged out of 43779 (in 74 pairings) input.
## 41541 paired-reads (in 51 unique pairings) successfully merged out of 43023 (in 67 pairings) input.
## 42832 paired-reads (in 103 unique pairings) successfully merged out of 44419 (in 132 pairings) input.
## 39546 paired-reads (in 60 unique pairings) successfully merged out of 41071 (in 86 pairings) input.
## 52136 paired-reads (in 59 unique pairings) successfully merged out of 54050 (in 80 pairings) input.
## 44831 paired-reads (in 61 unique pairings) successfully merged out of 46507 (in 84 pairings) input.
## 31296 paired-reads (in 29 unique pairings) successfully merged out of 32417 (in 42 pairings) input.
## 37505 paired-reads (in 75 unique pairings) successfully merged out of 38763 (in 88 pairings) input.
## 37004 paired-reads (in 45 unique pairings) successfully merged out of 38297 (in 57 pairings) input.
## 38940 paired-reads (in 171 unique pairings) successfully merged out of 40243 (in 304 pairings) input.
## 51488 paired-reads (in 39 unique pairings) successfully merged out of 53290 (in 54 pairings) input.
## 1325 paired-reads (in 9 unique pairings) successfully merged out of 1361 (in 12 pairings) input.
## 40625 paired-reads (in 91 unique pairings) successfully merged out of 42003 (in 134 pairings) input.
## 39794 paired-reads (in 48 unique pairings) successfully merged out of 41191 (in 61 pairings) input.
## 49501 paired-reads (in 88 unique pairings) successfully merged out of 51250 (in 109 pairings) input.
## 40810 paired-reads (in 48 unique pairings) successfully merged out of 42258 (in 67 pairings) input.
## 41040 paired-reads (in 110 unique pairings) successfully merged out of 42578 (in 178 pairings) input.
## 19946 paired-reads (in 229 unique pairings) successfully merged out of 23193 (in 1181 pairings) input.
## 35368 paired-reads (in 50 unique pairings) successfully merged out of 36673 (in 61 pairings) input.
## 30446 paired-reads (in 54 unique pairings) successfully merged out of 31483 (in 71 pairings) input.
## 35192 paired-reads (in 67 unique pairings) successfully merged out of 36469 (in 87 pairings) input.
## 39842 paired-reads (in 57 unique pairings) successfully merged out of 41199 (in 68 pairings) input.
## 37804 paired-reads (in 111 unique pairings) successfully merged out of 39137 (in 173 pairings) input.
## 41863 paired-reads (in 127 unique pairings) successfully merged out of 43468 (in 166 pairings) input.
## 34418 paired-reads (in 312 unique pairings) successfully merged out of 39195 (in 1494 pairings) input.
## 38525 paired-reads (in 49 unique pairings) successfully merged out of 39950 (in 68 pairings) input.
## 50823 paired-reads (in 45 unique pairings) successfully merged out of 52685 (in 65 pairings) input.
## 34240 paired-reads (in 113 unique pairings) successfully merged out of 35402 (in 135 pairings) input.
## 42851 paired-reads (in 51 unique pairings) successfully merged out of 44386 (in 69 pairings) input.
## 47161 paired-reads (in 79 unique pairings) successfully merged out of 48812 (in 112 pairings) input.
## 54422 paired-reads (in 182 unique pairings) successfully merged out of 56395 (in 287 pairings) input.
## 45582 paired-reads (in 39 unique pairings) successfully merged out of 47144 (in 50 pairings) input.
## 600 paired-reads (in 7 unique pairings) successfully merged out of 605 (in 9 pairings) input.
## 48985 paired-reads (in 44 unique pairings) successfully merged out of 50745 (in 66 pairings) input.
## 40179 paired-reads (in 85 unique pairings) successfully merged out of 41673 (in 113 pairings) input.
## 36995 paired-reads (in 78 unique pairings) successfully merged out of 38329 (in 99 pairings) input.
## 42699 paired-reads (in 58 unique pairings) successfully merged out of 44222 (in 72 pairings) input.
## 41997 paired-reads (in 88 unique pairings) successfully merged out of 43489 (in 150 pairings) input.
## 857 paired-reads (in 8 unique pairings) successfully merged out of 857 (in 8 pairings) input.
## 46754 paired-reads (in 82 unique pairings) successfully merged out of 48318 (in 107 pairings) input.
## 52624 paired-reads (in 35 unique pairings) successfully merged out of 54527 (in 51 pairings) input.
## 35627 paired-reads (in 72 unique pairings) successfully merged out of 36945 (in 102 pairings) input.
## 56977 paired-reads (in 88 unique pairings) successfully merged out of 58964 (in 120 pairings) input.
## 40295 paired-reads (in 36 unique pairings) successfully merged out of 41756 (in 48 pairings) input.
## 53794 paired-reads (in 95 unique pairings) successfully merged out of 56069 (in 145 pairings) input.
## 39427 paired-reads (in 86 unique pairings) successfully merged out of 41117 (in 175 pairings) input.
## 224 paired-reads (in 5 unique pairings) successfully merged out of 224 (in 5 pairings) input.
# Inspect the merger data.frame from the 2nd sample
head(mergers[[2]])
## sequence
## 1 AGCAGCCGCGGTAAGACGGGGGGGGCAAGTCTTCTTCGGAATGACTGGGCGTAAAGGGCACGTAGGCGGTGAATCGGGTTGAAAGTCAAAGTCGCCAAAAACTGGCGGAATGCTCTCGAAACCAATTCACTTGAGTGAGACAGAGGAGAGTGGAATTTCGTGTGTAGGGGTGAAATCCGGAGATCTACGAAGGAACGCCAAAAGCGAAGGCAGCTCTCTGGGTCCCTACCGACGCTGGGGTGCGAAAGCATGGGGAGCGAACAGGATTAGATACCCTG
## 2 AGCAGCCGCGGTAAGACGGGGGGGGCAAGTCTTCTTCGGAATGACTGGGCGTAAAGGGCACGTAGGCGGTGAATCGGGTTGAAAGTCAAAGTCGCCAAAAACTGGCGGAATGCTCTCGAAACCAATTCACTTGAGTGAGACAGAGGAGAGTGGAATTTCGTGTGTAGGGGTGAAATCCGGAGATCTACGAAGGAACGCCAAAAGCGAAGGCAGCTCTCTGGGTCCCTACCGACGCTGGGGTGCGAAAGCATGGGGAGCGAACGGGATTAGATACCCTG
## 3 AGCAGCCGCGGTAATACAGAGGATGCAAGCGTTATCCGGAATGATTGGGCGTAAAGCGTCTGTAGGTGGCTTTTTAAGTCCGCCGTCAAATCCCAGGGCTCAACCCTGGACAGGCGGTGGAAACTGCCAAGCTGGAGTACGGTAGGGGCAGAGGGAATTTCCGGTGGAGCGGTGAAATGCGTAGAGATCGGAAAGAACACCAACGGTGAAAGCACTCTGCTGGGCCGACACTGACACTGAGAGACGAAAGCTAGGGGAGCGAATGGGATTAGATACCCTG
## 7 AGCAGCCGCGGTAATACAGAGGATGCAAGCGTTATCCGGAATGATTGGGCGTAAAGCGTCTGTAGGTGGCTTTTTAAGTCCGCCGTCAAATCCCAGGGCTCAACCCTGGACAGGCGGTGGAAACTGCCAAGCTGGAGTACGGTAGGGGCAGAGGGAATTTCCGGTGGAGCGGTGAAATGCGTAGAGATCGGAAAGAACACCAACGGTGAAAGCACTCTGCTGGGCCGACACTGACACTGAGAGACGAAAGCTAGGGGAGCGAACGGGATTAGATACCCTG
## 8 AGCAGCCGCGGTAATACAGAGGATGCAAGCGTTATCCGGAATGATTGGGCGTAAAGCGTCTGTAGGTGGCTTTTTAAGTCCGCCGTCAAATCCCAGGGCTCAACCCTGGACAGGCGGTGGAAACTGCCAAGCTGGAGTACGGTAGGGGCAGAGGGAATTTCCGGTGGAGCGGTGAAATGCGTAGAGATCGGAAAGAACACCAACGGTGAAAGCACTCTGCTGGGCCGACACTGACACTGAGAGACGAAAGCTAGGGGAGCGAACAGGATTAGATACCCTG
## 9 AGCAGCCGCGGTAATACAGAGGATGCAAGCGTTATCCGGAATGATTGGGCGTAAAGCGTCTGTAGGTGGCTTTTTAAGTCCGCCGTCAAATCCCAGGGCTCAACCCTGGACAGGCGGTGGAAACTGCCAAGCTGGAGTACGGTAGGGGCAGAGGGAATTTCCGGTGGAGCGGTGAAATGCGTAGAGATCGGAAAGAACACCAACGGTGAAAGCACTCTGCTGGGCCGACACTGACACTGAGAGACGAAAGCTAGGGGAGCGAATAGGATTAGATACCCTG
## abundance forward reverse nmatch nmismatch nindel prefer accept
## 1 24920 1 1 192 0 0 1 TRUE
## 2 12078 1 2 192 0 0 1 TRUE
## 3 9169 2 3 190 0 0 1 TRUE
## 7 110 2 34 190 0 0 1 TRUE
## 8 85 2 6 190 0 0 1 TRUE
## 9 71 2 39 190 0 0 1 TRUE
# The `mergers` object is a list of `data.frames` from each sample. Each
# `data.frame` contains the merged `$sequence`, its `$abundance`, and the
# indices of the `$forward` and `$reverse` sequence variants that were merged.
# Paired reads that did not exactly overlap were removed by `mergePairs`,
# further reducing spurious output.
################################################################################ CONSTRUCT
################################################################################ SEQUENCE
################################################################################ TABLE
# Can now construct an amplicon sequence variant (ASV) table, which is a
# higher-resolution version of the OTU table produced by traditional methods.
seqtab <- makeSequenceTable(mergers)
dim(seqtab)
## [1] 78 2417
## Output: [1] 78 2417
# Inspect distribution of sequence lengths
table(nchar(getSequences(seqtab)))
##
## 240 247 250 251 252 253 254 255 256 257 261 263 264 266 269 272
## 3 1 7 1 2 1 5 3 4 2 1 2 1 1 1 1
## 273 275 276 278 279 280 281 282 285 290 291 294 295 299 308 313
## 11 1 2 99 45 2061 117 3 1 1 3 2 2 3 1 2
## 314 316 317 318 321 325 326 329 332 352 353 356 364 377 379 444
## 1 2 1 1 1 2 1 3 3 1 1 1 1 1 2 5
################################################################################ REMOVE
################################################################################ CHIMERAS
# The core dada method corrects substitution and indel errors, but chimeras
# remain. Fortunately, the accuracy of sequence variants after denoising makes
# identifying chimeric ASVs simpler than when dealing with fuzzy OTUs. Chimeric
# sequences are identified if they can be exactly reconstructed by combining a
# left-segment and a right-segment from two more abundant “parent” sequences.
seqtab.nochim <- removeBimeraDenovo(seqtab, method = "consensus", multithread = FALSE,
verbose = TRUE)
## Identified 627 bimeras out of 2417 input sequences.
# Output: Identified 627 bimeras out of 2417 input sequences.
dim(seqtab.nochim)
## [1] 78 1790
# Output: [1] 78 1790
sum(seqtab.nochim)/sum(seqtab)
## [1] 0.9774347
# Output: [1] 0.9774347
################################################################################ TRACK
################################################################################ READS
################################################################################ THROUGH
################################################################################ THE
################################################################################ PIPELINE
# As a final progress check, we’ll look at the number of reads that made it
# through each step in the pipeline:
getN <- function(x) sum(getUniques(x))
track <- cbind(out, sapply(dadaFs, getN), sapply(dadaRs, getN), sapply(mergers, getN),
rowSums(seqtab.nochim))
# If processing a single sample, remove the sapply calls: e.g. replace
# sapply(dadaFs, getN) with getN(dadaFs)
colnames(track) <- c("input", "filtered", "denoisedF", "denoisedR", "merged", "nonchim")
rownames(track) <- sample.names
head(track)
## input filtered denoisedF denoisedR merged nonchim
## CABO_109_16S_R1 55692 49955 49859 49863 48038 47625
## CABO_121_16S_R1 54309 48508 48450 48428 46838 46413
## CABO_025_16S_R1 56613 51025 50906 50889 48966 48278
## CABO_037_16S_R1 54473 48613 48499 48519 46774 46310
## CABO_145_16S_R1 46982 42505 42432 42413 40913 40629
## CABO_002_16S_R1 55213 47658 47580 47493 45889 45378
# Total number of reads that passed quality filtering
sum(seqtab.nochim)
## [1] 3046486
# Output: [1] 3,046,486
################################################################################ ASSIGN
################################################################################ TAXONOMY
# It is common at this point, especially in 16S/18S/ITS amplicon sequencing, to
# assign taxonomy to the sequence variants. The DADA2 package provides a native
# implementation of the naive Bayesian classifier method for this purpose. The
# assignTaxonomy function takes as input a set of sequences to be classified
# and a training set of reference sequences with known taxonomy, and outputs
# taxonomic assignments with at least minBoot bootstrap confidence.
# We maintain formatted training fastas for the RDP training set, GreenGenes
# clustered at 97% identity, and the Silva reference database, and additional
# trainings fastas suitable for protists and certain specific environments have
# been contributed. For fungal taxonomy, the General Fasta release files from
# the UNITE ITS database can be used as is. To follow along, download the
# silva_nr99_v138.1_train_set.fa.gz file, and place it in the directory with
# the fastq files.
taxa <- assignTaxonomy(seqtab.nochim, "C:/Users/jwils/OneDrive/Documents/Grad_Studies/Microbial_Leaf_Spec_Project/microbe_data/MiSeq_data/MiSeq_16S/Phenology/taxa/silva_nr99_v138.1_train_set.fa.gz",
multithread = FALSE)
## NOTE: Extensions: The dada2 package also implements a method to make species
## level assignments based on exact matching between ASVs and sequenced
## reference strains. Recent analysis suggests that exact matching (or 100%
## identity) is the only appropriate way to assign species to 16S gene
## fragments. Currently, species-assignment training fastas are available for
## the Silva and RDP 16S databases. To follow the optional species addition
## step, download the silva_species_assignment_v138.1.fa.gz file, and place it
## in the directory with the fastq files.
taxa <- addSpecies(taxa, "C:/Users/jwils/OneDrive/Documents/Grad_Studies/Microbial_Leaf_Spec_Project/microbe_data/MiSeq_data/MiSeq_16S/Phenology/taxa/silva_species_assignment_v138.1.fa.gz")
# Let’s inspect the taxonomic assignments:
taxa.print <- taxa # Removing sequence rownames for display only
rownames(taxa.print) <- NULL
head(taxa.print)
## Kingdom Phylum Class Order
## [1,] "Bacteria" "Proteobacteria" "Alphaproteobacteria" "Rickettsiales"
## [2,] "Bacteria" "Proteobacteria" "Alphaproteobacteria" "Rickettsiales"
## [3,] "Bacteria" "Proteobacteria" "Alphaproteobacteria" "Rickettsiales"
## [4,] "Bacteria" "Proteobacteria" "Alphaproteobacteria" "Rickettsiales"
## [5,] "Bacteria" "Cyanobacteria" "Cyanobacteriia" "Chloroplast"
## [6,] "Bacteria" "Cyanobacteria" "Cyanobacteriia" "Chloroplast"
## Family Genus Species
## [1,] "Mitochondria" NA NA
## [2,] "Mitochondria" NA NA
## [3,] "Mitochondria" NA NA
## [4,] "Mitochondria" NA NA
## [5,] NA NA NA
## [6,] NA NA NA
The recently developed IdTaxa taxonomic classification method is also available via the DECIPHER Bioconductor package. The paper introducing the IDTAXA algorithm reports classification performance that is better than the long-time standard set by the naive Bayesian classifier. Here we include a code block that allows you to use IdTaxa as a drop-in replacement for assignTaxonomy (and it’s faster as well!).
Trained classifiers are available from http://DECIPHER.codes/Downloads.html.
Download the SILVA SSU r132 (modified) file to follow along.
if (!requireNamespace(“BiocManager”, quietly=TRUE)) install.packages(“BiocManager”) BiocManager::install(“DECIPHER”)
library(DECIPHER)
packageVersion("DECIPHER")
## [1] '3.2.0'
dna <- DNAStringSet(getSequences(seqtab.nochim)) # Create a DNAStringSet from the ASVs
load("C:/Users/jwils/OneDrive/Documents/Grad_Studies/Microbial_Leaf_Spec_Project/microbe_data/MiSeq_data/MiSeq_16S/Phenology/taxa/IDTaxa/SILVA_SSU_r138_2019.RData") # CHANGE TO THE PATH OF YOUR TRAINING SET
ids <- IdTaxa(dna, trainingSet, strand = "top", processors = NULL, verbose = FALSE) # use all processors
ranks <- c("domain", "phylum", "class", "order", "family", "genus", "species") # ranks of interest
# Convert the output object of class 'Taxa' to a matrix analogous to the output
# from assignTaxonomy
taxid <- t(sapply(ids, function(x) {
m <- match(ranks, x$rank)
taxa <- x$taxon[m]
taxa[startsWith(taxa, "unclassified_")] <- NA
taxa
}))
colnames(taxid) <- ranks
rownames(taxid) <- getSequences(seqtab.nochim)
# It is more convenient to use short names for our ASVs (e.g. ASV21) rather
# than the full DNA sequence when working with some of the tables and
# visualization.
# Create a new matrix seqtab.print as a copy of seqtab.nochim
seqtab.print <- as.matrix(seqtab.nochim)
# Rename the column names of seqtab.print to ASVXXXX format
colnames(seqtab.print) <- paste0("ASV", seq_along(colnames(seqtab.nochim)))
# Print the dimensions of seqtab.print
dim(seqtab.print)
## [1] 78 1790
# if (!require('BiocManager', quietly = TRUE)) install.packages('BiocManager')
# BiocManager::install('phyloseq')
# if (!require(devtools)) { install.packages('devtools') }
# devtools::install_github('erocoar/ggparl')
library(phyloseq)
library(Biostrings)
library(ggplot2)
library(RColorBrewer)
library(cowplot)
library(ggsignif)
library(ggpubr)
library(tidyverse)
library(vegan)
library(olsrr)
library(plyr)
library(dplyr)
library(kableExtra)
library(factoextra)
library(devtools)
library(GGally)
library(ggsci)
library(ggbreak)
library(ggparl)
library(readxl)
################################################################################ READ
################################################################################ &
################################################################################ LOAD
################################################################################ IN
################################################################################ METADATA
meta <- read_excel("CABO_samples_2022-10-27-MetaData-v2.xlsx", sheet = "Meta-data",
col_types = "text")
colnames(meta)
## [1] "Number" "Name"
## [3] "Alias" "Barcode"
## [5] "Coordinate" "sample_id"
## [7] "Plant_ID" "Tag_ID"
## [9] "Species" "Number of Reads MiSeq"
## [11] "Project" "Collection-Date-All"
## [13] "Collection-Day" "Collection-Month"
## [15] "Collection-Year" "Collection-Time-All"
## [17] "Locality-Code-All" "Plant-Order"
## [19] "Plant-Family" "Days-Since-New-Year"
## [21] "GDD-Weather-Station" "Growing-Degree-Days-5C"
## [23] "Locality-Code-Nitrogen" "Nitrogen-Concentration"
## [25] "Functional-Group-Deciduousness" "Functional-Group-Leaf-Type"
# * qc here * generally removing low abundance samples and low abundance ASVs *
# then remove negative controls seqtab.print.colfiltered<-seqtab.print#[ ,
# colSums(seqtab.print)>10]
asv <- as.data.frame(seqtab.print) #as.data.frame(seqtab.print.colfiltered)
asv$Name <- unlist(lapply(strsplit(rownames(asv), "[_.]"), function(r) {
if (r[1] == "BlankpcrCES") {
return("BlankpcrCES")
} else {
return(paste(r[1:3], collapse = "_"))
}
}))
# asv <- asv[rownames(asv) != 'CABO_144_16S_R1_F_filt.fastq', ] # To remove
# duplicate sample completely
asv[1:10, 1790:ncol(asv)]
## ASV1790 Name
## CABO_109_16S_R1_F_filt.fastq 0 CABO_109_16S
## CABO_121_16S_R1_F_filt.fastq 0 CABO_121_16S
## CABO_025_16S_R1_F_filt.fastq 0 CABO_025_16S
## CABO_037_16S_R1_F_filt.fastq 0 CABO_037_16S
## CABO_145_16S_R1_F_filt.fastq 0 CABO_145_16S
## CABO_002_16S_R1_F_filt.fastq 0 CABO_002_16S
## CABO_014_16S_R1_F_filt.fastq 0 CABO_014_16S
## CABO_110_16S_R1_F_filt.fastq 0 CABO_110_16S
## CABO_026_16S_R1_F_filt.fastq 0 CABO_026_16S
## CABO_038_16S_R1_F_filt.fastq 0 CABO_038_16S
asv_joined <- plyr::join(asv, meta, by = "Name", type = "left")
dim(asv)
## [1] 78 1791
dim(meta)
## [1] 385 26
dim(asv_joined)
## [1] 78 1816
summary(rowSums(seqtab.print))
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 224 36380 40707 39058 45436 56182
summary(colSums(seqtab.print))
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 2 5 11 1702 30 805530
asv_joined[grepl("control", asv_joined$Species, ignore.case = T) | asv_joined$Alias ==
"BlankpcrCES", 1791:ncol(asv_joined)]
## Name Number Alias Barcode Coordinate sample_id Plant_ID
## 43 CABO_193_16S 376 CABO_193 VAL12600250 H08 <NA> <NA>
## 49 CABO_194_16S 378 CABO_194 VAL12600250 H09 <NA> <NA>
## 56 CABO_195_16S 380 CABO_195 VAL12600250 H10 <NA> <NA>
## 64 CABO_198_16S 382 CABO_198 VAL12600250 H11 <NA> <NA>
## 70 CABO_199_16S 384 CABO_199 VAL12600250 H12 <NA> <NA>
## 78 BlankpcrCES 1 BlankpcrCES MPS133710 <NA> <NA> <NA>
## Tag_ID Species Number of Reads MiSeq Project
## 43 <NA> Kit3_NegativeControl 3,216 Controls
## 49 <NA> Positive_Control 29,254 Controls
## 56 <NA> Positive_Control 48,970 Controls
## 64 <NA> Kit2_NegativeControl 2,024 Controls
## 70 <NA> Kit1_NegativeControl 2,225 Controls
## 78 <NA> other 1,302 <NA>
## Collection-Date-All Collection-Day Collection-Month Collection-Year
## 43 2/9/2022 9 2 2022
## 49 3/2/2022 2 3 2022
## 56 3/2/2022 2 3 2022
## 64 4/21/2022 21 4 2022
## 70 12/2/2021 2 12 2021
## 78 <NA> <NA> <NA> <NA>
## Collection-Time-All Locality-Code-All Plant-Order Plant-Family
## 43 <NA> AAFC <NA> <NA>
## 49 <NA> AAFC <NA> <NA>
## 56 <NA> AAFC <NA> <NA>
## 64 <NA> AAFC <NA> <NA>
## 70 <NA> AAFC <NA> <NA>
## 78 <NA> <NA> <NA> <NA>
## Days-Since-New-Year GDD-Weather-Station Growing-Degree-Days-5C
## 43 <NA> <NA> <NA>
## 49 <NA> <NA> <NA>
## 56 <NA> <NA> <NA>
## 64 <NA> <NA> <NA>
## 70 <NA> <NA> <NA>
## 78 <NA> <NA> <NA>
## Locality-Code-Nitrogen Nitrogen-Concentration Functional-Group-Deciduousness
## 43 <NA> <NA> <NA>
## 49 <NA> <NA> <NA>
## 56 <NA> <NA> <NA>
## 64 <NA> <NA> <NA>
## 70 <NA> <NA> <NA>
## 78 <NA> <NA> <NA>
## Functional-Group-Leaf-Type
## 43 <NA>
## 49 <NA>
## 56 <NA>
## 64 <NA>
## 70 <NA>
## 78 <NA>
negControlVals <- ceiling(colMeans(asv_joined[grepl("NegativeControl", asv_joined$Species,
ignore.case = T), grepl("ASV", colnames(asv_joined))]))
# * get asv columns from neg controls, * remove those counts from all other
# row's counts by column
cols <- colnames(asv_joined)[grepl("ASV", colnames(asv_joined))]
asv_negRm <- asv_joined[cols]
asv_negRm[cols] <- lapply(cols, function(c) asv_joined[[c]] - negControlVals[[c]])
asv_negRm <- as.matrix(asv_negRm)
asv_negRm[asv_negRm < 0] <- 0
asv_negRm <- cbind(asv_negRm, asv_joined[, !grepl("ASV", colnames(asv_joined))])
asv_joined[1:10, 1:10]
## ASV1 ASV2 ASV3 ASV4 ASV5 ASV6 ASV7 ASV8 ASV9 ASV10
## 1 27005 0 0 12734 7322 0 0 33 9 181
## 2 0 24920 12078 0 0 9169 0 0 0 0
## 3 25961 0 0 12094 7405 0 172 0 156 14
## 4 0 25375 12874 0 0 7318 56 0 10 0
## 5 0 22536 12548 0 0 5133 0 0 0 0
## 6 37 18918 11121 0 0 9791 0 0 0 0
## 7 21 24324 13329 0 31 3929 0 5 30 0
## 8 29533 0 0 14601 9431 0 0 8 21 24
## 9 0 22359 10015 0 0 6762 0 4 0 0
## 10 0 18002 9410 0 0 7518 0 0 0 0
asv_negRm[1:10, 1:10]
## ASV1 ASV2 ASV3 ASV4 ASV5 ASV6 ASV7 ASV8 ASV9 ASV10
## 1 26991 0 0 12734 7322 0 0 33 9 181
## 2 0 24912 12078 0 0 9169 0 0 0 0
## 3 25947 0 0 12094 7405 0 172 0 156 14
## 4 0 25367 12874 0 0 7318 56 0 10 0
## 5 0 22528 12548 0 0 5133 0 0 0 0
## 6 23 18910 11121 0 0 9791 0 0 0 0
## 7 7 24316 13329 0 31 3929 0 5 30 0
## 8 29519 0 0 14601 9431 0 0 8 21 24
## 9 0 22351 10015 0 0 6762 0 4 0 0
## 10 0 17994 9410 0 0 7518 0 0 0 0
sum(grepl("control", asv_negRm$Species, ignore.case = T))
## [1] 5
test <- asv_negRm[asv_negRm$Alias == "BlankpcrCES", ]
summary(as.numeric(test[1, grepl("ASV", colnames(test))]))
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.000000 0.000000 0.000000 0.005028 0.000000 9.000000
which(as.numeric(test[1, grepl("ASV", colnames(test))]) != 0)
## [1] 11
test[1, 1:11] #* not removing explicitly because this will be removed in the next block anyway,
## ASV1 ASV2 ASV3 ASV4 ASV5 ASV6 ASV7 ASV8 ASV9 ASV10 ASV11
## 78 0 0 0 0 0 0 0 0 0 0 9
# * aka, one ASV found in this blank PCR (ASV11) and it's already being
# removed.
############################################# SIDENOTE!:
# Just like with the `seqtab.print`, it's more convenient to use short names
# for our ASVs (e.g. ASV21) rather than the full DNA sequence when working with
# some of the tables and visualization.
# Create a copy of the taxa table
taxa_rdp <- taxa
# Rename the column names of taxa_rdp to ASVXXXX format
rownames(taxa_rdp) <- paste0("ASV", seq_along(rownames(taxa_rdp)))
# Create a copy of the taxid table
taxid_rdp <- taxid
# Rename the column names of taxid_rdp to ASVXXXX format
rownames(taxid_rdp) <- paste0("ASV", seq_along(rownames(taxid_rdp)))
asv_negRm <- asv_negRm[!grepl("NegativeControl", asv_negRm$Species, ignore.case = T) &
!asv_negRm$Alias == "BlankpcrCES", ]
scaleFactor <- exp(mean(log(rowSums(asv_negRm[, cols]))))
asv_scaled <- asv_negRm
asv_scaled[, cols] <- as.data.frame(t(apply(asv_scaled[, cols], MARGIN = 1, FUN = function(i) round(scaleFactor *
i/sum(i)))))
# asv_joined[1:10,1:10] asv_negRm[1:10,1:10] asv_scaled[1:10,1:10]
rdp <- as.data.frame(taxa_rdp)
asv_scaled_noPlants <- cbind(asv_scaled[, c(rownames(rdp[!rdp$Order %in% c("Chloroplast") &
!rdp$Family %in% c("Mitochondria"), ]))], asv_scaled[, !grepl("ASV", colnames(asv_scaled))])
dim(asv_scaled_noPlants)
## [1] 74 1758
asv_scaled_noPlants[1:10, 1:10]
## ASV7 ASV8 ASV9 ASV10 ASV12 ASV13 ASV14 ASV15 ASV16 ASV17
## 1 0 28 8 152 17 0 0 0 0 0
## 2 0 0 0 0 16 0 9 0 0 0
## 3 143 0 130 12 16 0 76 0 0 0
## 4 49 0 9 0 5 0 0 0 0 0
## 5 0 0 0 0 0 0 0 0 0 0
## 6 0 0 0 0 449 0 0 0 0 75
## 7 0 5 28 0 10 0 0 0 0 0
## 8 0 6 16 18 0 0 10 0 0 0
## 9 0 4 0 0 8 0 0 0 0 0
## 10 0 0 0 0 20 0 0 0 0 0
Diversity indices are statistics used to summarize the diversity of a community in which each member belongs to a unique group. In ecology, species richness refers to number of species and species evenness refers to homogeneity of the species. That is, the more equal the proportions for each of the groups, the more homogeneous, or even, they are. Different fields of application may use different terminology for these concepts.
Data Exploration and alpha diversity
Objective: To determine whether sequence depth was ‘enough’ to capture community dynamics
How:
################################################################################ CALCULATE
################################################################################ SHANNON
################################################################################ (`alphaDiv`),
################################################################################ ASV
################################################################################ RICHNESS
################################################################################ (`specnumber`),
################################################################################ &
################################################################################ SIMPSON
################################################################################ (`simpson`)
# And place as columns in joined metadata
library(vegan)
# meta_16s<-meta[grepl('16S', meta$Name),]
# asv_m<-plyr::join(asv_scaled_noPlants, meta_16s, by='Name')
asv_scaled_noPlants$alphaDiv <- vegan::diversity(asv_scaled_noPlants[, grepl("ASV",
colnames(asv_scaled_noPlants))], index = "shannon")
asv_scaled_noPlants$specnumber <- vegan::specnumber(asv_scaled_noPlants[, grepl("ASV",
colnames(asv_scaled_noPlants))])
asv_scaled_noPlants$simpson <- vegan::diversity(asv_scaled_noPlants[, grepl("ASV",
colnames(asv_scaled_noPlants))], index = "simpson")
asv_scaled_noPlants[1:10, 1748:ncol(asv_scaled_noPlants)]
## Collection-Time-All Locality-Code-All Plant-Order Plant-Family
## 1 0.48819444444444443 MSB_Chemin Fagales Betulaceae
## 2 0.60069444444444442 MSB_Parking Malpighiales Salicaceae
## 3 0.5 MSB_Chemin Fagales Betulaceae
## 4 0.58402777777777781 MSB_Parking Malpighiales Salicaceae
## 5 0.61944444444444446 MSB_Parking Malpighiales Salicaceae
## 6 14.24 MSB_Parking Malpighiales Salicaceae
## 7 0.57291666666666663 MSB_Parking Malpighiales Salicaceae
## 8 0.5180555555555556 MSB_Chemin Fagales Betulaceae
## 9 0.63263888888888886 MSB_Parking Malpighiales Salicaceae
## 10 0.66875000000000007 MSB_Parking Malpighiales Salicaceae
## Days-Since-New-Year GDD-Weather-Station Growing-Degree-Days-5C
## 1 200 Montreal-St-Hubert 1087
## 2 254 Montreal-St-Hubert 1992
## 3 159 Montreal-St-Hubert 437
## 4 172 Montreal-St-Hubert 605
## 5 200 Montreal-St-Hubert 1087
## 6 200 Montreal-St-Hubert 1087
## 7 254 Montreal-St-Hubert 1992
## 8 200 Montreal-St-Hubert 1087
## 9 159 Montreal-St-Hubert 437
## 10 159 Montreal-St-Hubert 437
## Locality-Code-Nitrogen Nitrogen-Concentration Functional-Group-Deciduousness
## 1 <NA> <NA> Deciduous
## 2 <NA> <NA> Deciduous
## 3 <NA> <NA> Deciduous
## 4 <NA> <NA> Deciduous
## 5 <NA> <NA> Deciduous
## 6 <NA> <NA> Deciduous
## 7 <NA> <NA> Deciduous
## 8 <NA> <NA> Deciduous
## 9 <NA> <NA> Deciduous
## 10 <NA> <NA> Deciduous
## Functional-Group-Leaf-Type alphaDiv specnumber simpson
## 1 Broadleaf 2.507189 26 0.8420858
## 2 Broadleaf 2.984186 22 0.9443376
## 3 Broadleaf 2.585833 64 0.7711666
## 4 Broadleaf 2.878291 47 0.8703732
## 5 Broadleaf 2.120503 28 0.6951853
## 6 Broadleaf 4.437583 117 0.9800234
## 7 Broadleaf 3.738649 66 0.9633074
## 8 Broadleaf 3.175233 29 0.9507891
## 9 Broadleaf 3.477090 44 0.9514739
## 10 Broadleaf 3.474596 37 0.9650746
# If we can see the entire graph, then we have captured the rare taxa and super
# abundant
preston <- vegan::prestondistr(t(asv_scaled_noPlants[, grepl("ASV", colnames(asv_scaled_noPlants))]))
preston_lognormal <- plot(preston)
preston_lognormal
## NULL
# Save the plot as a PDF file
pdf("preston_lognormal.pdf")
plot(preston)
dev.off()
## png
## 2
# Save as PNG
png("preston_lognormal.png", width = 7, height = 4.85, units = "in", res = 600)
plot(preston)
dev.off()
## png
## 2
# If we see the plateau then we have sampled all there was to sample
# Plot the species accumulation curve with custom axis labels
specaccum_samples <- plot(
specaccum(t(asv_scaled_noPlants[,grepl("ASV",colnames(asv_scaled_noPlants))])),
xlab = "Sampling Effort", # Custom label for the x-axis
ylab = "Cumulative ASVs (Kindt's Exact)" # Custom label for the y-axis
)
specaccum_samples
## NULL
# Open a JPEG device
jpeg("specaccum_samples.jpg")
# Generate the plot
specaccum_samples <- plot(
specaccum(t(asv_scaled_noPlants[, grepl("ASV", colnames(asv_scaled_noPlants))])),
xlab = "Sampling Effort", # Custom label for the x-axis
ylab = "Cumulative ASVs (Kindt's Exact)" # Custom label for the y-axis
)
# Close the JPEG device
dev.off()
## png
## 2
specaccum_positive_control <- plot(specaccum(t(asv_scaled_noPlants[!grepl("Positive_Control",asv_scaled_noPlants$Species),grepl("ASV",colnames(asv_scaled_noPlants))])),
xlab = "Sampling Effort", # Custom label for the x-axis
ylab = "Cumulative ASVs (Kindt's Exact)" # Custom label for the y-axis
)
specaccum_positive_control
## NULL
# Open a JPEG device
jpeg("specaccum_positive_control.jpg")
# Generate the plot
specaccum_positive_control <- plot(
specaccum(t(asv_scaled_noPlants[!grepl("Positive_Control", asv_scaled_noPlants$Species), grepl("ASV", colnames(asv_scaled_noPlants))])),
xlab = "Sampling Effort", # Custom label for the x-axis
ylab = "Cumulative ASVs (Kindt's Exact)" # Custom label for the y-axis
)
# Close the JPEG device
dev.off()
## png
## 2
# Open a JPEG device with the specified size
jpeg("combined_specaccum_plots.jpg", width = 7, height = 4.85, units = "in", res = 600)
# Set up the plotting layout to have 2 rows and 1 column
par(mfrow = c(1, 2))
# Generate the first plot
specaccum_samples <- plot(
specaccum(t(asv_scaled_noPlants[, grepl("ASV", colnames(asv_scaled_noPlants))])),
xlab = "Sampling Effort", # Custom label for the x-axis
ylab = "Cumulative ASVs (Kindt's Exact)" # Custom label for the y-axis
)
# Generate the second plot
specaccum_positive_control <- plot(
specaccum(t(asv_scaled_noPlants[!grepl("Positive_Control", asv_scaled_noPlants$Species), grepl("ASV", colnames(asv_scaled_noPlants))])),
xlab = "Sampling Effort", # Custom label for the x-axis
ylab = "Cumulative ASVs (Kindt's Exact)" # Custom label for the y-axis
)
# Close the JPEG device
dev.off()
## png
## 2
library(ggplot2)
library(car)
library(carData)
library(performance)
library(easystats)
library(lme4)
library(lmtest)
library(lmPerm)
library(MASS)
library(HH)
library(boot)
library(simpleboot)
library(MuMIn)
library(pwr)
library(multcomp)
library(tidyverse)
library(dplyr)
library(tidyr)
library(effects)
library(readr)
# Let's attach Functional Traits from `spectra` object from Shan/spectrolab:
# Create the full path to the CSV file in the other directory
spec_path_ref <- file.path("C:/Users/jwils/OneDrive/Documents/Grad_Studies/Microbial_Leaf_Spec_Project/Spectral_Files/Phenology/Processed_Spectra",
"ref_spec_phen_duplicate.csv")
# Read the CSV file
refl_trait_data <- read.csv(spec_path_ref)
# Join trait data
asv_scaled_noPlants <- plyr::join(asv_scaled_noPlants, refl_trait_data, by = "sample_id",
type = "left")
# Convert GDDs & Species from character to factor
asv_scaled_noPlants$`Growing-Degree-Days-5C` <- as.numeric(asv_scaled_noPlants$`Growing-Degree-Days-5C`)
asv_scaled_noPlants$Species <- as.factor(asv_scaled_noPlants$Species)
# Impute NAs with median for numeric columns asv_scaled_noPlants[,
# sapply(asv_scaled_noPlants, is.numeric)] <- lapply(asv_scaled_noPlants[,
# sapply(asv_scaled_noPlants, is.numeric)], function(x) ifelse(is.na(x),
# median(x, na.rm = TRUE), x))
dim(asv_scaled_noPlants)
## [1] 74 3821
dim(refl_trait_data)
## [1] 72 2061
# Create & Write 'asv_scaled_noPlants.csv'
write.csv(asv_scaled_noPlants, file = "asv_scaled_noPlants.csv")
getwd()
################################################################################ (a)
################################################################################ TOTAL
################################################################################ SHANNON
################################################################################ DIVERSITY
################################################################################ (ACROSS
################################################################################ ALL
################################################################################ GROWING
################################################################################ DEGREE
################################################################################ DAYS
################################################################################ &
################################################################################ HOSTS):
library(cowplot)
library(ggplot2)
library(vegan)
# Phenology_keep<-meta$Project=='Phenology-Group' # Set new funtion to use
# meta.Phenology<- meta[Phenology_keep,] #Get the desired files from the
# metadata
#------------------------------------------------------------------------------------------------------
# **IMPORTANT NOTE: This is wat I WOULD do, if I was using all sequence files
# for all projects, but since I pre-filtered to only have 'Phenology'
# sequences, the `asv_scaled_noPlants` is fine as-is!!!:
asv_scaled_noPlants_Phenology <- asv_scaled_noPlants[asv_scaled_noPlants$Project ==
"Phenology", ] #Get the desired files from the ASV table
#------------------------------------------------------------------------------------------------------
# x<-asv_scaled_noPlants_Phenology$
# x$newShannon<-diversity(x[,grepl('ASV',colnames(x))])
scale_custom_two <- list(scale_color_manual(values = c("darkorange", "#812e91")),
scale_fill_manual(values = c("darkorange", "#812e91")))
scale_custom_3 <- list(scale_color_manual(values = c("darkorange", "#812e91", "dodgerblue3")),
scale_fill_manual(values = c("darkorange", "#812e91", "dodgerblue3")))
scale_custom_three <- list(scale_color_manual(values = c("dodgerblue4", "slategrey",
"deeppink4")), scale_fill_manual(values = c("dodgerblue4", "slategrey", "deeppink4")))
scale_custom_8 <- list(scale_color_manual(values = c("darkslategrey", "darkgreen",
"darkolivegreen", "darkseagreen", "goldenrod1", "goldenrod2", "goldenrod3", "goldenrod4")),
scale_fill_manual(values = c("darkslategrey", "darkgreen", "darkolivegreen",
"darkseagreen", "goldenrod1", "goldenrod2", "goldenrod3", "goldenrod4")))
scale_custom_four <- list(scale_color_manual(values = c("black", "blue", "burlywood4",
"red4")), scale_fill_manual(values = c("black", "blue", "burlywood4", "red4")))
scale_custom_five <- list(scale_color_manual(values = c("black", "purple", "burlywood4",
"red4")), scale_fill_manual(values = c("black", "purple", "burlywood4", "red4")))
scale_custom_six <- list(scale_color_manual(values = c("black", "orange", "burlywood4",
"red4")), scale_fill_manual(values = c("black", "orange", "burlywood4", "red4")))
set.seed(19850)
Total_shannon = ggplot(asv_scaled_noPlants, aes(x = Project, y = alphaDiv, color = Project)) +
geom_boxplot(outlier.colour = "lightblue3", outlier.shape = 8, outlier.size = 1.5,
show.legend = F) + geom_point(position = position_jitterdodge()) + scale_y_continuous() +
scale_y_continuous() + ylab("Total Shannon Diversity H'") + scale_colour_manual(values = c("black",
"blue", "burlywood4", "red3")) + coord_cartesian(xlim = c(0, NA), clip = "off") +
coord_cartesian(ylim = c(0, NA), clip = "off") + theme_cowplot(12)
## Scale for y is already present.
## Adding another scale for y, which will replace the existing scale.
## Coordinate system already present. Adding new coordinate system, which will
## replace the existing one.
Total_shannon
# Save the plot as a JPEG image
ggsave(filename = "Total_shannon1.jpeg", plot = Total_shannon, device = "jpeg", width = 10,
height = 6, units = "in")
TS <- ggplot(asv_scaled_noPlants, aes(x = Project, y = alphaDiv, fill = Project)) +
geom_boxjitter(outlier.color = NA, jitter.shape = 21, jitter.color = NA, size = 1.1,
jitter.height = 0.05, jitter.width = 0.075, errorbar.draw = TRUE) + theme(legend.position = "none") +
ylab("Total Shannon Diversity H'") + ylim(c(0, NA)) + scale_custom_four
TS + theme_cowplot(12)
# Save the plot as a JPEG image
ggsave(filename = "Total_shannon2.jpeg", plot = TS, device = "jpeg", width = 10,
height = 6, units = "in")
################################################################################ (b)
################################################################################ TOTAL
################################################################################ SHANNON
################################################################################ DIVERSITY
################################################################################ (BETWEEN
################################################################################ HOST
################################################################################ TREE
################################################################################ SPECIES
################################################################################ ONLY):
Phenology_diversity <- ggplot(asv_scaled_noPlants, aes(x = Species, y = alphaDiv,
fill = Species)) + geom_boxjitter(outlier.color = NA, jitter.shape = 21, jitter.color = NA,
size = 1.1, jitter.height = 0.05, jitter.width = 0.075, errorbar.draw = TRUE) +
theme(legend.position = "none") + ylab(" Phenology Group Shannon H") + #scale_x_discrete(limits=c('Deciduous', 'Evergreen'))+ theme(legend.position
theme(legend.position = "none") + ylab(" Phenology Group Shannon H") + #scale_x_discrete(limits=c('Deciduous', 'Evergreen'))+ =
theme(legend.position = "none") + ylab(" Phenology Group Shannon H") + #scale_x_discrete(limits=c('Deciduous', 'Evergreen'))+ "none")
theme(legend.position = "none") + ylab(" Phenology Group Shannon H") + #scale_x_discrete(limits=c('Deciduous', 'Evergreen'))+ +
theme(legend.position = "none") + ylab(" Phenology Group Shannon H") + #scale_x_discrete(limits=c('Deciduous', 'Evergreen'))+ ylab("
theme(legend.position = "none") + ylab(" Phenology Group Shannon H") + #scale_x_discrete(limits=c('Deciduous', 'Evergreen'))+ Phenology
theme(legend.position = "none") + ylab(" Phenology Group Shannon H") + #scale_x_discrete(limits=c('Deciduous', 'Evergreen'))+ Group
theme(legend.position = "none") + ylab(" Phenology Group Shannon H") + #scale_x_discrete(limits=c('Deciduous', 'Evergreen'))+ Shannon
theme(legend.position = "none") + ylab(" Phenology Group Shannon H") + #scale_x_discrete(limits=c('Deciduous', 'Evergreen'))+ H")
theme(legend.position = "none") + ylab(" Phenology Group Shannon H") + #scale_x_discrete(limits=c('Deciduous', 'Evergreen'))+ +
theme(legend.position = "none") + ylab(" Phenology Group Shannon H") + #scale_x_discrete(limits=c('Deciduous', 'Evergreen'))+ #scale_x_discrete(limits=c('Deciduous',
theme(legend.position = "none") + ylab(" Phenology Group Shannon H") + #scale_x_discrete(limits=c('Deciduous', 'Evergreen'))+ 'Evergreen'))+
ylim(c(0, NA)) + scale_custom_3
Phenology_diversity + theme_cowplot(12)
# Save the plot as a JPEG image
ggsave(filename = "Total_shannon_spp.jpeg", plot = Phenology_diversity, device = "jpeg",
width = 10, height = 6, units = "in")
NOTE: Everything prior to this can be applied to the entire sequence dataset and then filtered by subproject, as I will do here for Phenology.
# Exclude rows with '323' in the `Growing-Degree-Days-5C` variable
asv_scaled_noPlants_filtered <- subset(asv_scaled_noPlants, `Growing-Degree-Days-5C` !=
323)
asv_scaled_noPlants_Phenology_filtered <- subset(asv_scaled_noPlants_Phenology, `Growing-Degree-Days-5C` !=
323)
# Convert GDD variable to factor with desired order
asv_scaled_noPlants_Phenology_filtered$`Growing-Degree-Days-5C` <- factor(asv_scaled_noPlants_Phenology_filtered$`Growing-Degree-Days-5C`,
levels = c(437, 605, 1087, 1606, 1992, 2140, 2219))
asv_scaled_noPlants_filtered$`Growing-Degree-Days-5C` <- factor(asv_scaled_noPlants_filtered$`Growing-Degree-Days-5C`,
levels = c(437, 605, 1087, 1606, 1992, 2140, 2219))
#-------------------------------------------------------------------------------
## NOTE: For Later Statistics (Need GDDs to be CONTINUOUS Variable!!!)
#-------------------------------------------------------------------------------
# Create new objects & convert `Species` to factor & `Growing-Degree-Days-5C`
# to numeric for ALL objects used in stats
asv_scaled_noPlants_Phen_filt_LMM <- as.data.frame(asv_scaled_noPlants_Phenology_filtered)
# Convert the factor to numeric without changing the values
asv_scaled_noPlants_Phen_filt_LMM$`Growing-Degree-Days-5C` <- as.numeric(as.character(asv_scaled_noPlants_Phen_filt_LMM$`Growing-Degree-Days-5C`))
# Convert to `Species` to factor
asv_scaled_noPlants_Phen_filt_LMM$Species <- as.factor(asv_scaled_noPlants_Phen_filt_LMM$Species)
# Convert to `sample_id` to factor
asv_scaled_noPlants_Phen_filt_LMM$sample_id <- as.factor(asv_scaled_noPlants_Phen_filt_LMM$sample_id)
# Convert to `Plant_ID` to factor
asv_scaled_noPlants_Phen_filt_LMM$Plant_ID <- as.factor(asv_scaled_noPlants_Phen_filt_LMM$Plant_ID)
# Rename the 'Growing-Degree-Days-5C' variable to 'GDD5C'
colnames(asv_scaled_noPlants_Phen_filt_LMM)[colnames(asv_scaled_noPlants_Phen_filt_LMM) ==
"Growing-Degree-Days-5C"] <- "GDD_5C"
# Create a column `GDD_5C_bins` to bin (categorize) continuous GDDs
sampling_points <- c(437, 605, 1087, 1606, 1992, 2140, 2219)
asv_scaled_noPlants_Phen_filt_LMM$GDD_5C_bins <- cut(asv_scaled_noPlants_Phen_filt_LMM$GDD_5C,
breaks = c(-Inf, sampling_points, Inf), labels = c("437", "605", "1087", "1606",
"1992", "2140", "2219", "2220+"), include.lowest = TRUE)
# asv_scaled_noPlants_Phen_filt_LMM<-plyr::join(asv_scaled_noPlants_Phen_filt_LMM,
# refl_trait_data, by='sample_id', type='left')
# Convert `Plant_ID` to factor
asv_scaled_noPlants_Phen_filt_LMM$Plant_ID <- as.factor(asv_scaled_noPlants_Phen_filt_LMM$Plant_ID)
# Subset a dataset for each Species
betula_data <- subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia")
populus_data <- subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides")
################################################################################ (c)
################################################################################ TOTAL
################################################################################ SHANNON
################################################################################ DIVERSITY
################################################################################ (BETWEEN
################################################################################ GDDs
################################################################################ ONLY):
Phenology_diversity_gdd <- ggplot(asv_scaled_noPlants_Phenology_filtered, aes(x = `Growing-Degree-Days-5C`,
y = alphaDiv, fill = `Growing-Degree-Days-5C`)) + geom_boxjitter(outlier.color = NA,
jitter.shape = 21, jitter.color = NA, size = 1.1, jitter.height = 0.05, jitter.width = 0.075,
errorbar.draw = TRUE) + theme(legend.position = "none") + ylab("Phenology Group Shannon H'") +
# scale_x_discrete(limits=c('Deciduous', 'Evergreen'))+
ylim(c(0, NA)) + scale_custom_8
Phenology_diversity_gdd + theme_cowplot(12)
################################################################################
## (d) SHANNON DIVERSITY (BETWEEN SPECIES & GDDs!):
################################################################################
library(ggsignif)
# Define colors for each species (colorblind-friendly choices)
species_colors <- c("blue", "#800080", "#00ffff", "#e7298a", "purple", "darkorange", "#a6761d")
# Define colors for each collection month (unique and colorblind-friendly choices)
collection_month_colors <- c("darkorange", "mediumpurple", "violet", "aquamarine3", "#ecb21e", "salmon", "skyblue2")
sig_df_shannon <- data.frame(
xmin = c(0.75, 1.8, 2.8, 3.8, 4.8, 5.8, 6.8), # Adjust for left (Betula)
xmax = c(1.15, 2.2, 3.2, 4.2, 5.2, 6.2, 7.2), # Adjust for right (Populus)
y_position = c(3.85, 4.1, 4.63, 4.27, 3.93, 4.2, 4.25),
annotation = c("*", "**", "**", "**", "**", "**", "**")
)
# Make sure GDD is a factor with consistent ordering
gdd_levels_shannon <- levels(asv_scaled_noPlants_Phenology_filtered$`Growing-Degree-Days-5C`)
# Calculate numeric x-positions
grey_rects_shannon <- data.frame(
xmin = seq(1.5, length(gdd_levels_shannon) - 0.5, by = 2),
xmax = seq(2.5, length(gdd_levels_shannon) + 0.5, by = 2)
)
# Plot with updated dataset and GDD order
Phenology_diversity_gddspec2 <- ggplot(asv_scaled_noPlants_Phenology_filtered, aes(x = `Growing-Degree-Days-5C`, y = alphaDiv)) +
geom_rect(data = grey_rects_shannon, aes(xmin = xmin, xmax = xmax, ymin = 0, ymax = Inf),
fill = "grey85", inherit.aes = FALSE) +
geom_rect(data = asv_scaled_noPlants_Phenology_filtered, aes(xmin = as.numeric(`Growing-Degree-Days-5C`)-0.5, xmax = as.numeric(`Growing-Degree-Days-5C`)+0.5,
ymin = -Inf, ymax = 0.0025, fill = `Collection-Month`), alpha = 1) +
geom_boxjitter(aes(fill = Species), outlier.color = NA, jitter.shape = 21, jitter.color = NA, size = 0.5,
jitter.height = 0.05, jitter.width = 0.075, jitter.size = 0.75, errorbar.draw = TRUE, errorbar.size = 0.3, linewidth = 0.3) +
ylab("Shannon Index (H')") +
ylim(c(0, NA)) +
scale_x_discrete() +
scale_fill_manual(
values = collection_month_colors,
name = "Host Species",
labels = function(x) {
dplyr::recode(
x,
"Betula_populifolia" = "Grey Birch",
"Populus_tremuloides" = "Trembling Aspen"
)
}
) +
geom_segment(data = sig_df_shannon,
aes(x = xmin, xend = xmax, y = y_position, yend = y_position),
inherit.aes = FALSE, linewidth = 0.5) +
geom_text(data = sig_df_shannon,
aes(x = (xmin + xmax)/2, y = y_position + 0.05, label = annotation),
size = 3, vjust = 0) +
labs(x = expression("Growing Degree Days (" * T[base] * " = 5"~degree*C * ")"), fill = "Species") +
guides(
fill = guide_legend(
nrow = 1,
title = "Host Species", # or whatever title is showing
keyheight = unit(0.3, "cm"), # smaller height of boxes/shapes
keywidth = unit(0.3, "cm"), # smaller width
override.aes = list(size = 1) # smaller symbol size (for points/shapes)
)
) +
theme_cowplot(12) +
theme(
legend.position = "bottom",
legend.box = "horizontal",
axis.title.x = element_text(size = 9),
axis.title.y = element_text(size = 9),
axis.text.x = element_text(size = 7.5),
axis.text.y = element_text(size = 7.5),
legend.title = element_text(size = 8),
legend.text = element_text(size = 8),
panel.border = element_rect(color = "black", size = 1),
plot.margin = unit(c(5, 5, 1, 1), "pt")
)
Phenology_diversity_gddspec2
# Save the plot as a JPEG image
ggsave(filename = "Shannon_phenology_16S.jpeg", plot = Phenology_diversity_gddspec2,
device = "jpeg", width = 10, height = 6, units = "in")
################################################################################ (a)
################################################################################ TOTAL
################################################################################ ASV
################################################################################ RICHNESS
################################################################################ (ACROSS
################################################################################ ALL
################################################################################ SPECIES
################################################################################ &
################################################################################ GDDs):
Total_Richness = ggplot(asv_scaled_noPlants, aes(x = Project, y = specnumber, color = Project)) +
geom_boxplot(outlier.colour = "lightblue3", outlier.shape = 8, outlier.size = 1.5,
show.legend = F) + geom_point(position = position_jitterdodge()) + scale_y_continuous() +
scale_y_continuous() + ylab("Total ASV Richness") + coord_cartesian(xlim = c(0,
NA), clip = "off") + coord_cartesian(ylim = c(0, NA), clip = "off") + scale_custom_five +
theme_cowplot(12)
Total_Richness
# Save the plot as a JPEG image
ggsave(filename = "Total_richness1.jpeg", plot = Total_Richness, device = "jpeg",
width = 10, height = 6, units = "in")
TD <- ggplot(asv_scaled_noPlants, aes(x = Project, y = specnumber, fill = Project)) +
geom_boxjitter(outlier.color = NA, jitter.shape = 21, jitter.color = NA, size = 1.1,
jitter.height = 0.05, jitter.width = 0.075, errorbar.draw = TRUE) + theme(legend.position = "none") +
ylab("Total ASV Richness") + ylim(c(0, NA)) + scale_custom_five
TD + theme_cowplot(12)
# Save the plot as a JPEG image
ggsave(filename = "Total_richness2.jpeg", plot = TD, device = "jpeg", width = 10,
height = 6, units = "in")
################################################################################ (b)
################################################################################ TOTAL
################################################################################ ASV
################################################################################ RICHNESS
################################################################################ (BETWEEN
################################################################################ SPECIES,
################################################################################ ACROSS
################################################################################ ALL
################################################################################ GDDs):
scale_custom_8 <- list(scale_color_manual(values = c("darkslategrey", "darkgreen",
"darkolivegreen", "darkseagreen", "goldenrod1", "goldenrod2", "goldenrod3", "goldenrod4")),
scale_fill_manual(values = c("darkslategrey", "darkgreen", "darkolivegreen",
"darkseagreen", "goldenrod1", "goldenrod2", "goldenrod3", "goldenrod4")))
set.seed(19850)
Phenology_Richness <- ggplot(asv_scaled_noPlants, aes(x = Species, y = specnumber,
fill = Species)) + geom_boxjitter(outlier.color = NA, jitter.shape = 21, jitter.color = NA,
size = 1.1, jitter.height = 0.05, jitter.width = 0.075, errorbar.draw = TRUE) +
theme(legend.position = "none") + ylab(" Phenology Group ASV Richness") + #scale_x_discrete(limits=c('Deciduous', 'Evergreen'))+ theme(legend.position
theme(legend.position = "none") + ylab(" Phenology Group ASV Richness") + #scale_x_discrete(limits=c('Deciduous', 'Evergreen'))+ =
theme(legend.position = "none") + ylab(" Phenology Group ASV Richness") + #scale_x_discrete(limits=c('Deciduous', 'Evergreen'))+ "none")
theme(legend.position = "none") + ylab(" Phenology Group ASV Richness") + #scale_x_discrete(limits=c('Deciduous', 'Evergreen'))+ +
theme(legend.position = "none") + ylab(" Phenology Group ASV Richness") + #scale_x_discrete(limits=c('Deciduous', 'Evergreen'))+ ylab("
theme(legend.position = "none") + ylab(" Phenology Group ASV Richness") + #scale_x_discrete(limits=c('Deciduous', 'Evergreen'))+ Phenology
theme(legend.position = "none") + ylab(" Phenology Group ASV Richness") + #scale_x_discrete(limits=c('Deciduous', 'Evergreen'))+ Group
theme(legend.position = "none") + ylab(" Phenology Group ASV Richness") + #scale_x_discrete(limits=c('Deciduous', 'Evergreen'))+ ASV
theme(legend.position = "none") + ylab(" Phenology Group ASV Richness") + #scale_x_discrete(limits=c('Deciduous', 'Evergreen'))+ Richness")
theme(legend.position = "none") + ylab(" Phenology Group ASV Richness") + #scale_x_discrete(limits=c('Deciduous', 'Evergreen'))+ +
theme(legend.position = "none") + ylab(" Phenology Group ASV Richness") + #scale_x_discrete(limits=c('Deciduous', 'Evergreen'))+ #scale_x_discrete(limits=c('Deciduous',
theme(legend.position = "none") + ylab(" Phenology Group ASV Richness") + #scale_x_discrete(limits=c('Deciduous', 'Evergreen'))+ 'Evergreen'))+
ylim(c(0, NA)) + scale_custom_3
Phenology_Richness + theme_cowplot(12)
## Warning: The following aesthetics were dropped during statistical transformation: y.
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
## the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
## variable into a factor?
# Save the plot as a JPEG image
ggsave(filename = "Total_richness_spp.jpeg", plot = Phenology_Richness, device = "jpeg",
width = 10, height = 6, units = "in")
################################################################################ (c)
################################################################################ TOTAL
################################################################################ ASV
################################################################################ RICHNESS
################################################################################ (BETWEEN
################################################################################ GDDs
################################################################################ ONLY):
# Plot
Phenology_Richness_ggdd <- ggplot(asv_scaled_noPlants_Phenology_filtered, aes(x = `Growing-Degree-Days-5C`,
y = specnumber, fill = `Growing-Degree-Days-5C`)) + geom_boxjitter(outlier.color = NA,
jitter.shape = 21, jitter.color = NA, size = 1.1, jitter.height = 0.05, jitter.width = 0.075,
errorbar.draw = TRUE) + theme(legend.position = "none") + ylab(" Phenology Group ASV Richness") +
# scale_x_discrete(limits=c('Deciduous', 'Evergreen'))+
ylim(c(0, NA)) + scale_x_discrete(breaks = as.character(sort(as.numeric(unique(asv_scaled_noPlants_Phenology_filtered$`Growing-Degree-Days-5C`)),
decreasing = F))) + scale_custom_8
Phenology_Richness_ggdd + theme_cowplot(12) + ggpubr::stat_compare_means(method = "wilcox",
comparisons = lapply(c(2:8), function(i) c(1, i)))
################################################################################
# (d) TOTAL ASV RICHNESS (BETWEEN SPECIES AND GDDs):
################################################################################
# Define colors for each species (colorblind-friendly choices)
species_colors <- c("blue", "#800080", "#00ffff", "#e7298a", "purple", "#e6ab02", "#a6761d")
# Define colors for each collection month (unique and colorblind-friendly choices)
collection_month_colors <- c("darkorange", "mediumpurple", "violet", "aquamarine3", "#ecb21e", "salmon", "skyblue2")
sig_df_richness <- data.frame(
xmin = c(0.75, 1.8, 2.8, 3.8, 4.8, 5.8, 6.7), # Adjust for left (Betula)
xmax = c(1.15, 2.2, 3.2, 4.2, 5.2, 6.2, 7.1), # Adjust for right (Populus)
y_position = c(52, 67, 73, 113, 73, 127, 68),
annotation = c("*", "*", "n.s.", "n.s.", "n.s.", "n.s.", "n.s.")
)
# Make sure GDD is a factor with consistent ordering
gdd_levels_richness <- levels(asv_scaled_noPlants_Phenology_filtered$`Growing-Degree-Days-5C`)
# Calculate numeric x-positions
grey_rects_richness <- data.frame(
xmin = seq(1.5, length(gdd_levels_richness) - 0.5, by = 2),
xmax = seq(2.5, length(gdd_levels_richness) + 0.5, by = 2)
)
# Plot with updated dataset and GDD order
Phenology_richness_gddspec2 <- ggplot(asv_scaled_noPlants_Phenology_filtered, aes(x = `Growing-Degree-Days-5C`, y = specnumber)) +
geom_rect(data = asv_scaled_noPlants_Phenology_filtered, aes(xmin = as.numeric(`Growing-Degree-Days-5C`)-0.5, xmax = as.numeric(`Growing-Degree-Days-5C`)+0.5,
ymin = -Inf, ymax = 0.05, fill = `Collection-Month`), alpha = 1) +
geom_rect(data = grey_rects_richness, aes(xmin = xmin, xmax = xmax, ymin = 0, ymax = Inf),
fill = "grey85", inherit.aes = FALSE) +
geom_boxjitter(aes(fill = Species), outlier.color = NA, jitter.shape = 21, jitter.color = NA, size = 0.5,
jitter.height = 0.05, jitter.width = 0.075, jitter.size = 0.75, errorbar.draw = TRUE, errorbar.size = 0.3, linewidth = 0.3) +
ylab("ASV Richness") +
ylim(c(0, NA)) +
scale_x_discrete() +
scale_fill_manual(
values = collection_month_colors,
name = "Host Species",
labels = function(x) {
dplyr::recode(
x,
"Betula_populifolia" = "Grey Birch",
"Populus_tremuloides" = "Trembling Aspen"
)
}
) +
geom_segment(data = sig_df_richness,
aes(x = xmin, xend = xmax, y = y_position, yend = y_position),
inherit.aes = FALSE, linewidth = 0.5) +
geom_text(data = sig_df_richness,
aes(x = (xmin + xmax)/2, y = y_position + 3, label = annotation),
size = 3, vjust = 0) +
labs(x = expression("Growing Degree Days (" * T[base] * " = 5"~degree*C * ")"), fill = "Species") +
guides(
fill = guide_legend(
nrow = 1,
title = "Host Species",
keyheight = unit(0.3, "cm"), # smaller height of boxes/shapes
keywidth = unit(0.3, "cm"), # smaller width
override.aes = list(size = 1) # smaller symbol size (for points/shapes)
)
) +
theme_cowplot(12) +
theme(
legend.position = "bottom",
legend.box = "horizontal",
axis.title.x = element_text(size = 9),
axis.title.y = element_text(size = 9),
axis.text.x = element_text(size = 7.5),
axis.text.y = element_text(size = 7.5),
legend.title = element_text(size = 8),
legend.text = element_text(size = 8),
panel.border = element_rect(color = "black", size = 1),
plot.margin = unit(c(5, 5, 1, 1), "pt")
)
Phenology_richness_gddspec2
betula_data <- subset(asv_scaled_noPlants_Phenology_filtered, Species == "Betula_populifolia")
# Filter the dataset to include only 'Populus_tremuloides'
populus_data <- subset(asv_scaled_noPlants_Phenology_filtered, Species == "Populus_tremuloides")
# Arrange the plots in a grid
alpha_inter_combined <- arrangeGrob(Phenology_richness_gddspec2, Phenology_diversity_gddspec2,
ncol = 2, nrow = 1)
# Save the combined plot
ggsave("alpha_inter_combined.jpg", alpha_inter_combined, width = 7, height = 4.85,
dpi = 600) # Adjust width and height as needed
# Save the plot as a JPEG image
ggsave(filename = "ASVrich_phenology_16S.jpeg", plot = Phenology_richness_gddspec2,
device = "jpeg", width = 10, height = 6, units = "in")
# write.csv(asv_scaled_noPlants_filtered,
# file='asv_scaled_noPlants_filtered.csv') getwd()
write.csv(asv_scaled_noPlants_Phenology_filtered, file = "asv_scaled_noPlants_Phenology_filtered.csv")
getwd()
################################################################################ COMBINING
################################################################################ PLOTS
################################################################################ AS
################################################################################ PANELS
################################################################################ INTO
################################################################################ RESPECTIVE
################################################################################ FIGURES
library(gridExtra)
# Total Alpha Diversity (for sequencing QC):
total_alpha_combined <- arrangeGrob(Phenology_Richness, Phenology_diversity, ncol = 3)
ggsave("total_alpha_combined.png", total_alpha_combined, width = 14, height = 8)
# Alpha Diversity as function of GDDs:
alpha_combined <- arrangeGrob(Phenology_richness_gddspec2, Phenology_diversity_gddspec2,
ncol = 3)
ggsave("alpha_combined.png", alpha_combined, width = 16, height = 6)
alpha_combined <- arrangeGrob(Phenology_richness_gddspec2, Phenology_diversity_gddspec2,
ncol = 2, nrow = 1)
fig_div_combined2 <- arrangeGrob(alpha_combined, Phenology_beta_nosize3, ncol = 1,
nrow = 2)
# Save
ggsave("fig_div_combined2.tiff", fig_div_combined2, width = 7, height = 7, units = "in",
dpi = 600, compression = "lzw", device = "tiff")
ggsave("fig_div_combined2.png", fig_div_combined2, width = 7, height = 7, units = "in",
dpi = 600)
ggsave("fig_div_combined2.pdf", fig_div_combined2, width = 7, height = 7, units = "in",
dpi = 600)
library(vegan)
library(ape)
##
## Attaching package: 'ape'
## The following object is masked from 'package:dplyr':
##
## where
## The following object is masked from 'package:ggpubr':
##
## rotate
## The following object is masked from 'package:ShortRead':
##
## zoom
## The following object is masked from 'package:Biostrings':
##
## complement
asv_scaled_noPlants_Phen_filt_LMM$Phenology <- factor(case_when(asv_scaled_noPlants_Phen_filt_LMM$GDD_5C %in%
c(437, 605, 1087) ~ "Early", asv_scaled_noPlants_Phen_filt_LMM$GDD_5C %in% c(1606,
1992) ~ "Mid", asv_scaled_noPlants_Phen_filt_LMM$GDD_5C %in% c(2140, 2219) ~
"Late"), levels = c("Early", "Mid", "Late"))
# Beta diversity (Bray-Curtis Dissimilarity Matrix based on PCoA):
asv <- asv_scaled_noPlants_Phen_filt_LMM[rowSums(asv_scaled_noPlants_Phen_filt_LMM[,
grepl("ASV", colnames(asv_scaled_noPlants_Phen_filt_LMM))]) != 0, ]
distance = "bray"
dist.mat <- vegan::vegdist(asv[, grepl("ASV", colnames(asv))], method = distance)
pcoa.asv <- pcoa(dist.mat)
pcoa.table_phenology <- cbind(pcoa.asv$vectors[, 1:5], asv[, !grepl("ASV", colnames(asv))])
pcoa.table_phenology$Axis.1
## [1] 0.172990915 -0.160417228 0.089633403 -0.137778686 -0.182711925
## [6] -0.107417389 -0.191714815 0.005812714 -0.133546614 -0.196482124
## [11] 0.155715035 -0.130177164 0.222805410 -0.265857986 0.032925337
## [16] 0.180274180 -0.202144127 0.293604464 -0.113876597 -0.165279197
## [21] 0.247081412 0.222148020 -0.254030611 0.195688758 0.261408514
## [26] -0.137569346 0.331588093 0.202132811 0.410065088 -0.242986581
## [31] 0.282431033 0.004189992 -0.233313244 -0.311376730 -0.185685765
## [36] -0.251531887 0.148529026 0.112469931 -0.249501779 -0.140473987
## [41] 0.276188179 0.306215098 0.255484021 0.074953961 -0.318060118
## [46] 0.241504033 0.416314896 0.043839324 0.387404595 -0.235910171
## [51] -0.261444559 0.301889038 -0.214363096 -0.168285059 0.199102302
## [56] -0.252504377 -0.268634581 0.315001014 0.194243054 0.249847932
## [61] -0.273345386 -0.238569969 -0.196844192 0.387319935 -0.235258160
## [66] -0.138371013 -0.182186263 0.404216493 -0.128844321 -0.317042221
## [71] -0.201480746
# To find the total proportion of variance explained by each PCoA axes, simply
# view the output of the `pcoa.asv` object, which has the PCoA values, and then
# use the `Rel_corr_eig` column values (where rows are the Axis) as the
# proportion of variation explained by the axes because this column is the
# variance explained, corrected for negative eigenvalues
head(pcoa.asv)
## $correction
## [1] "none" "1"
##
## $note
## [1] "No correction was applied to the negative eigenvalues"
##
## $values
## Eigenvalues Relative_eig Rel_corr_eig Broken_stick Cum_corr_eig
## 1 3.846673745 0.1261088252 0.1219025590 0.0698340731 0.1219026
## 2 3.165851493 0.1037888417 0.1004221497 0.0553413195 0.2223247
## 3 1.354241913 0.0443972814 0.0432646241 0.0480949427 0.2655893
## 4 1.066328812 0.0349583777 0.0341807681 0.0432640248 0.2997701
## 5 1.010342083 0.0331229164 0.0324143484 0.0396408364 0.3321844
## 6 0.936395418 0.0306986591 0.0300812804 0.0367422857 0.3622657
## 7 0.791843317 0.0259596829 0.0255205624 0.0343268267 0.3877863
## 8 0.737157922 0.0241668843 0.0237952006 0.0322564333 0.4115815
## 9 0.675862989 0.0221573997 0.0218613034 0.0304448391 0.4334428
## 10 0.650789302 0.0213353873 0.0210702114 0.0288345332 0.4545130
## 11 0.624032382 0.0204581921 0.0202260122 0.0273852578 0.4747390
## 12 0.611497396 0.0200472469 0.0198305248 0.0260677348 0.4945695
## 13 0.579998645 0.0190145961 0.0188367176 0.0248600053 0.5134063
## 14 0.577013041 0.0189167165 0.0187425197 0.0237451781 0.5321488
## 15 0.547819513 0.0179596399 0.0178214439 0.0227099814 0.5499702
## 16 0.532981647 0.0174731973 0.0173532990 0.0217437978 0.5673235
## 17 0.515592552 0.0169031156 0.0168046611 0.0208380007 0.5841282
## 18 0.497008621 0.0162938626 0.0162183254 0.0199854858 0.6003465
## 19 0.493267175 0.0161712035 0.0161002801 0.0191803328 0.6164468
## 20 0.478737182 0.0156948542 0.0156418489 0.0184175563 0.6320886
## 21 0.462501538 0.0151625871 0.0151296032 0.0176929186 0.6472182
## 22 0.435406141 0.0142742953 0.0142747248 0.0170027875 0.6614930
## 23 0.432243267 0.0141706040 0.0141749340 0.0163440260 0.6756679
## 24 0.424531851 0.0139177941 0.0139316335 0.0157139063 0.6895995
## 25 0.415394381 0.0136182325 0.0136433400 0.0151100415 0.7032429
## 26 0.408189880 0.0133820411 0.0134160331 0.0145303314 0.7166589
## 27 0.388559781 0.0127384907 0.0127966900 0.0139729178 0.7294556
## 28 0.383364017 0.0125681534 0.0126327601 0.0134361491 0.7420884
## 29 0.374992016 0.0122936869 0.0123686177 0.0129185508 0.7544570
## 30 0.361440047 0.0118494010 0.0119410438 0.0124188007 0.7663980
## 31 0.346336405 0.0113542453 0.0114645135 0.0119357089 0.7778625
## 32 0.344641443 0.0112986779 0.0114110363 0.0114682007 0.7892736
## 33 0.334195020 0.0109562038 0.0110814445 0.0110153021 0.8003550
## 34 0.321384634 0.0105362298 0.0106772680 0.0105761278 0.8110323
## 35 0.316527306 0.0103769878 0.0105240160 0.0101498703 0.8215563
## 36 0.307424305 0.0100785563 0.0102368100 0.0097357917 0.8317931
## 37 0.290190204 0.0095135559 0.0096930623 0.0093332152 0.8414862
## 38 0.281644542 0.0092333961 0.0094234409 0.0089415191 0.8509096
## 39 0.271762911 0.0089094381 0.0091116686 0.0085601309 0.8600213
## 40 0.262355877 0.0086010391 0.0088148702 0.0081885218 0.8688362
## 41 0.255036264 0.0083610740 0.0085839314 0.0078262030 0.8774201
## 42 0.249959286 0.0081946310 0.0084237493 0.0074727212 0.8858438
## 43 0.241616636 0.0079211267 0.0081605329 0.0071276556 0.8940044
## 44 0.231151512 0.0075780395 0.0078303511 0.0067906148 0.9018347
## 45 0.220251706 0.0072207018 0.0074864547 0.0064612341 0.9093212
## 46 0.218967934 0.0071786148 0.0074459508 0.0061391729 0.9167671
## 47 0.197101633 0.0064617529 0.0067560540 0.0058241130 0.9235232
## 48 0.192015352 0.0062950050 0.0065955784 0.0055157565 0.9301188
## 49 0.184461477 0.0060473598 0.0063572484 0.0052138242 0.9364760
## 50 0.178298443 0.0058453117 0.0061628005 0.0049180537 0.9426388
## 51 0.164889808 0.0054057249 0.0057397488 0.0046281986 0.9483786
## 52 0.161394480 0.0052911345 0.0056294688 0.0043440270 0.9540080
## 53 0.158881664 0.0052087547 0.0055501878 0.0040653202 0.9595582
## 54 0.150756069 0.0049423663 0.0052938197 0.0037918720 0.9648520
## 55 0.138724387 0.0045479213 0.0049142118 0.0035234877 0.9697662
## 56 0.115310547 0.0037803252 0.0041754891 0.0032599831 0.9739417
## 57 0.101244764 0.0033191945 0.0037317040 0.0030011839 0.9776734
## 58 0.085605112 0.0028064663 0.0032382623 0.0027469251 0.9809117
## 59 0.080406411 0.0026360328 0.0030742397 0.0024970500 0.9839859
## 60 0.072550399 0.0023784823 0.0028263771 0.0022514101 0.9868123
## 61 0.065386465 0.0021436209 0.0026003501 0.0020098642 0.9894127
## 62 0.055743524 0.0018274881 0.0022961087 0.0017722781 0.9917088
## 63 0.041285382 0.0013534943 0.0018399444 0.0015385240 0.9935487
## 64 0.035527955 0.0011647436 0.0016582936 0.0013084803 0.9952070
## 65 0.027535907 0.0009027334 0.0014061390 0.0010820310 0.9966131
## 66 0.022074424 0.0007236849 0.0012338255 0.0008590656 0.9978470
## 67 0.012826088 0.0004204887 0.0009420341 0.0006394784 0.9987890
## 68 0.010981421 0.0003600134 0.0008838336 0.0004231686 0.9996728
## 69 0.000000000 0.0000000000 0.0003271596 0.0002100399 1.0000000
## 70 -0.006662378 -0.0002184185 0.0000000000 0.0000000000 1.0000000
## 71 -0.017031713 -0.0005583653 0.0000000000 0.0000000000 1.0000000
## Cumul_br_stick
## 1 0.06983407
## 2 0.12517539
## 3 0.17327034
## 4 0.21653436
## 5 0.25617520
## 6 0.29291748
## 7 0.32724431
## 8 0.35950074
## 9 0.38994558
## 10 0.41878011
## 11 0.44616537
## 12 0.47223311
## 13 0.49709311
## 14 0.52083829
## 15 0.54354827
## 16 0.56529207
## 17 0.58613007
## 18 0.60611556
## 19 0.62529589
## 20 0.64371345
## 21 0.66140636
## 22 0.67840915
## 23 0.69475318
## 24 0.71046708
## 25 0.72557713
## 26 0.74010746
## 27 0.75408037
## 28 0.76751652
## 29 0.78043507
## 30 0.79285387
## 31 0.80478958
## 32 0.81625778
## 33 0.82727309
## 34 0.83784921
## 35 0.84799908
## 36 0.85773488
## 37 0.86706809
## 38 0.87600961
## 39 0.88456974
## 40 0.89275826
## 41 0.90058447
## 42 0.90805719
## 43 0.91518484
## 44 0.92197546
## 45 0.92843669
## 46 0.93457586
## 47 0.94039998
## 48 0.94591573
## 49 0.95112956
## 50 0.95604761
## 51 0.96067581
## 52 0.96501984
## 53 0.96908516
## 54 0.97287703
## 55 0.97640052
## 56 0.97966050
## 57 0.98266168
## 58 0.98540861
## 59 0.98790566
## 60 0.99015707
## 61 0.99216693
## 62 0.99393921
## 63 0.99547774
## 64 0.99678622
## 65 0.99786825
## 66 0.99872731
## 67 0.99936679
## 68 0.99978996
## 69 1.00000000
## 70 1.00000000
## 71 1.00000000
##
## $vectors
## Axis.1 Axis.2 Axis.3 Axis.4 Axis.5
## 1 0.172990915 0.356609746 -0.0889810635 -0.0475420080 0.149241265
## 2 -0.160417228 0.048101482 -0.1758273324 0.0883071159 -0.235872012
## 3 0.089633403 -0.152222504 -0.0557115398 0.2684289581 0.096689594
## 4 -0.137778686 -0.054270207 0.0212900564 0.1683452960 -0.003731655
## 5 -0.182711925 -0.046095586 -0.0294943738 0.0317833802 -0.085983692
## 6 -0.107417389 -0.046932478 -0.0251243104 -0.0370461379 0.015832033
## 7 -0.191714815 -0.091034761 0.0748338762 0.1328812589 0.066658543
## 8 0.005812714 0.059902675 -0.1553700514 0.2468327879 0.148945882
## 9 -0.133546614 -0.006557472 -0.1449385928 0.0649216963 -0.118620633
## 10 -0.196482124 0.011985493 -0.1126614085 0.0193565751 -0.175422130
## 11 0.155715035 0.419961523 -0.0661099645 -0.1293837127 0.048278452
## 12 -0.130177164 -0.044308148 -0.0665018671 0.0362462475 -0.049500806
## 13 0.222805410 0.090228226 0.3750842660 0.0253383637 -0.145098431
## 14 -0.265857986 -0.021692166 0.0130570990 -0.0013806748 -0.055194958
## 15 0.032925337 0.228225701 -0.2138684019 0.0180359897 0.121692732
## 16 0.180274180 0.344635440 0.0209930154 -0.0758254069 -0.030680333
## 17 -0.202144127 0.015657731 -0.0568020766 -0.0927043878 -0.050630246
## 18 0.293604464 -0.436743855 -0.2140574213 -0.1876353585 0.018344988
## 19 -0.113876597 -0.019799940 -0.0725595223 -0.0435569995 0.003964008
## 20 -0.165279197 -0.077073227 0.0998240438 -0.0571763185 0.094054750
## 21 0.247081412 0.402655449 0.1319574162 -0.1192607855 -0.111399583
## 22 0.222148020 0.429313044 -0.0589672234 -0.0526154145 0.104882210
## 23 -0.254030611 -0.012995123 0.0138024328 -0.0543429174 -0.015271899
## 24 0.195688758 -0.355957322 -0.1985552619 -0.1608989641 0.026553890
## 25 0.261408514 -0.021408036 0.0919076223 0.3453009260 0.040153870
## 26 -0.137569346 -0.036843563 -0.0570049323 0.0185760249 -0.056138181
## 27 0.331588093 -0.081884669 0.2635578680 0.1259502457 -0.079378080
## 28 0.202132811 0.414462670 -0.0343175536 -0.0500469786 0.036676927
## 29 0.410065088 -0.277917345 -0.0403730289 -0.0396733994 -0.004434186
## 30 -0.242986581 -0.016625214 0.0189484809 0.0051770524 -0.093598951
## 31 0.282431033 -0.424134530 -0.1999717881 -0.2287308819 0.008011975
## 32 0.004189992 0.284576206 -0.1588137569 -0.1411870979 0.125681052
## 33 -0.233313244 0.018940808 -0.0901854906 0.0569148334 -0.085612389
## 34 -0.311376730 -0.115466460 0.2469593474 -0.0776706534 0.201741646
## 35 -0.185685765 -0.046565424 0.0092957946 0.0478590692 -0.079826945
## 36 -0.251531887 -0.037157659 -0.0217163566 0.0739278205 -0.177362572
## 37 0.148529026 0.166356662 -0.0352895751 0.1584995673 0.110029700
## 38 0.112469931 0.431421699 -0.1720638185 -0.1517967852 0.131198704
## 39 -0.249501779 -0.068097998 0.1182392139 0.0262656312 0.109758275
## 40 -0.140473987 0.017046217 -0.1221873859 0.0757869361 -0.172175843
## 41 0.276188179 -0.332804436 -0.0005132704 -0.2333097802 -0.046635025
## 42 0.306215098 0.358831987 0.2541351614 -0.0731269376 -0.147818407
## 43 0.255484021 -0.309220426 -0.0693114997 0.2792978471 0.155894926
## 44 0.074953961 0.357848034 -0.1826021188 -0.1135519575 0.112394642
## 45 -0.318060118 -0.084144262 0.2151175031 -0.0998896490 0.142342736
## 46 0.241504033 0.119301138 0.3440940230 0.0510489635 -0.246101150
## 47 0.416314896 -0.321050881 -0.0019027795 -0.1238010263 -0.063208577
## 49 0.043839324 0.040250576 -0.0408156442 0.2496998260 0.221117916
## 50 0.387404595 0.038841565 0.3147049521 0.1526204725 -0.132729783
## 51 -0.235910171 0.014244131 -0.0143111631 0.0007816708 -0.102257199
## 52 -0.261444559 -0.044909614 0.0844630019 -0.1005878951 0.114073892
## 53 0.301889038 -0.252062990 0.0026490799 -0.1511560248 -0.107602757
## 54 -0.214363096 -0.118153734 0.1846906750 -0.1531323265 0.171357716
## 56 -0.168285059 -0.031748697 -0.0752867254 0.0398134330 -0.104436551
## 57 0.199102302 0.205333123 -0.0871123555 0.1727389965 0.236848558
## 58 -0.252504377 -0.078942643 0.1717744401 -0.1095361657 0.138212089
## 59 -0.268634581 -0.030159610 -0.0003669592 -0.0201851707 -0.137072110
## 60 0.315001014 -0.297771024 -0.0581994463 0.2479212137 0.135212272
## 61 0.194243054 -0.216289626 0.0284501616 -0.0271513154 0.053815041
## 62 0.249847932 0.423191419 0.0753215368 -0.0595113672 -0.046001602
## 64 -0.273345386 -0.047631076 0.0865137364 -0.0448210161 0.040487961
## 65 -0.238569969 -0.032909942 0.0397480269 -0.0060563592 -0.004728307
## 66 -0.196844192 -0.016536781 -0.0216610130 0.0066826681 -0.047462452
## 67 0.387319935 -0.337929824 -0.0384529539 -0.1085762567 0.008396629
## 68 -0.235258160 -0.064291851 0.1153355607 -0.0584987883 0.147813134
## 69 -0.138371013 0.072975401 -0.2245258852 0.0678566461 -0.264793014
## 70 -0.182186263 -0.062824739 -0.0280578365 0.0407423057 -0.080669764
## 71 0.404216493 -0.156669018 0.0616242519 -0.0160308257 -0.048850636
## 72 -0.128844321 0.096102138 -0.2416803418 0.0501288942 -0.172629927
## 73 -0.317042221 -0.089551551 0.2072460774 -0.0750277179 0.134183488
## 74 -0.201480746 -0.049613871 0.0666353697 -0.0716432506 0.108389290
## Axis.6 Axis.7 Axis.8 Axis.9 Axis.10
## 1 0.074402435 0.0373690837 0.0074610359 0.0168042160 -0.0159621833
## 2 0.056756063 -0.0708114678 0.1193950514 0.1651109083 -0.1171097582
## 3 -0.095407726 -0.0481422194 0.0004778031 0.0007860789 0.0202675562
## 4 -0.026734252 0.1447125644 0.1742255406 -0.1638365073 0.0983119975
## 5 0.082579147 0.0538498148 -0.2077617992 0.0692618083 -0.0434716606
## 6 -0.374608583 -0.0756789794 -0.0402416486 0.0876725582 0.1969428420
## 7 -0.019431736 0.0295384857 0.2148872679 -0.1138599872 -0.2431068494
## 8 -0.087654016 0.0880394310 -0.0258315726 0.0717038170 -0.0568563413
## 9 -0.152561049 0.1384960998 -0.0665084769 -0.0532547072 0.0014610641
## 10 -0.012848777 0.0021245890 -0.0055861079 -0.0533240207 -0.2990779555
## 11 0.038686626 -0.1320075658 -0.0179038863 -0.0191048016 -0.0462285029
## 12 -0.183521350 0.1863107264 -0.2379822211 -0.1348206122 -0.1900046106
## 13 -0.103739933 -0.0602090980 -0.0281455550 0.0744946878 0.0126029100
## 14 0.261853011 -0.0077127434 -0.1491212840 0.1345343169 0.1471454709
## 15 -0.048909437 0.1660304150 0.0187840875 0.0763392751 0.0894725742
## 16 -0.015700338 0.0307731034 0.0541462562 0.0311986295 0.0105300428
## 17 -0.078425531 -0.3321893771 -0.0801275209 -0.1728101224 -0.1654110160
## 18 0.069323013 0.0547474811 0.0086728254 -0.0412429801 0.0062136183
## 19 -0.312907489 -0.1769186827 -0.0802095573 -0.0749798172 0.2059282429
## 20 -0.176394480 -0.0213813867 0.0780894919 0.1760678567 -0.1564193780
## 21 -0.007704142 0.0788654024 0.0106225697 -0.0027498324 -0.0281460072
## 22 0.043436160 0.0687876968 -0.0035308234 0.0045392799 -0.0810800287
## 23 0.106195978 -0.1700789185 -0.1017651914 -0.0460015360 -0.0345464293
## 24 -0.022021127 0.0932217776 0.0278249046 0.0448804110 -0.0005737348
## 25 0.092258932 -0.0907293774 0.0003515509 -0.0176175084 0.0257008705
## 26 -0.152508975 0.2100259009 -0.1082530506 -0.0782709920 0.2547297255
## 27 -0.056128561 -0.0772211026 0.0005373677 0.0033650894 -0.0100500345
## 28 0.043166954 0.0406532695 0.0306095014 -0.0258568312 -0.0135353564
## 29 0.123861527 -0.0641066163 -0.0114206523 -0.0855454533 0.0084905527
## 30 0.106379619 -0.1269219661 -0.0843935652 0.0449490465 -0.0202434477
## 31 0.048119732 0.0804241862 0.0209926583 -0.0253121958 -0.0114720259
## 32 -0.128333727 -0.1844923630 -0.0609118438 -0.1525843987 0.0454855682
## 33 0.163130145 0.0683301768 -0.1933092950 0.0848955022 -0.0442623878
## 34 0.091765538 0.1005460210 0.0951380314 0.0187680915 0.0058155338
## 35 0.030943234 0.0225713068 -0.0743034897 -0.1103334605 -0.0480056346
## 36 0.083089707 0.0978738297 0.0519411884 -0.0337396873 0.0266771868
## 37 0.068151651 -0.1190355219 -0.0354021523 0.0389544401 -0.0188001063
## 38 0.066635102 0.0704528900 0.0177455541 0.0036118005 -0.0119362598
## 39 0.100677102 0.0514707605 0.1572936601 -0.0796803123 -0.0895454006
## 40 -0.009787622 0.0213333953 0.2644455730 0.0527786207 0.1567543294
## 41 -0.078629301 0.0646244294 0.0528290917 0.1337746419 -0.0475194523
## 42 -0.027008675 0.0767236295 -0.0228618852 -0.0144556334 0.0023602505
## 43 0.033768145 -0.0855231534 -0.0278948210 0.0540451023 0.0210294277
## 44 0.045868473 0.0015598148 0.0144113593 0.0175909953 0.0244843661
## 45 0.185925135 0.0194755953 0.0364918870 -0.0013264431 0.0084283674
## 46 -0.134622408 0.0613759262 -0.0224622184 -0.0221653618 -0.0001321747
## 47 0.052436232 -0.0447968708 0.0047496778 -0.0532266492 -0.0004089584
## 49 -0.063457920 0.1151498082 -0.0354138718 -0.1215743669 -0.0374039620
## 50 0.006894311 -0.0388080182 -0.0329827778 -0.0028652778 0.0379363054
## 51 0.212510350 -0.0642122220 0.0503097579 0.0849955130 0.2465674615
## 52 -0.041288362 -0.1479933485 0.0812932738 -0.2296841225 0.1394631160
## 53 0.027967943 0.0251632386 -0.0038217527 -0.1016145517 -0.0024481157
## 54 -0.190101837 0.0009007946 0.0723176433 0.2846490642 -0.0552369961
## 56 -0.115343286 0.1945619664 -0.1666331548 -0.0433859656 -0.0358161384
## 57 0.077163811 0.0110426369 -0.0281426559 0.0822056640 0.0333315429
## 58 -0.030794569 0.0393314186 0.0049101580 0.1446158213 -0.0255410776
## 59 0.199933625 0.0412784974 -0.1534094193 0.0343653648 0.1325575463
## 60 0.076157875 -0.0962629176 -0.0385119464 0.0365987120 0.0284534456
## 61 -0.152222273 0.0223901851 0.0282533205 0.2787621854 -0.0087306457
## 62 0.056042585 0.0362702168 0.0367636256 -0.0106917390 0.0404336571
## 64 0.101572875 -0.0122062836 -0.1464271530 0.0164233329 0.0523629687
## 65 0.005589365 0.0700361792 0.0406725433 -0.0845114815 0.0909592451
## 66 -0.052782221 0.0270724613 0.3675230624 -0.1893590166 0.0722905147
## 67 0.095897616 0.0047034893 0.0029130836 -0.0506287074 -0.0066781765
## 68 -0.026060389 -0.0784907074 -0.0175067207 -0.0092650211 0.0541390361
## 69 0.001271126 -0.1064877052 0.1932346905 0.1424699006 -0.0212893721
## 70 -0.071784271 0.1534710624 -0.0211317839 -0.0060414672 -0.1000923997
## 71 0.088878264 -0.0513611389 -0.0027187698 -0.1050409006 -0.0124691137
## 72 -0.019774926 -0.2628700005 0.1024857221 0.1026429338 -0.0623014283
## 73 0.167161402 0.0490836490 0.0355606165 -0.0434388272 -0.0914337069
## 74 -0.117251525 -0.2041136552 -0.1457328081 -0.0396543697 -0.0439805089
## Axis.11 Axis.12 Axis.13 Axis.14 Axis.15
## 1 -0.016939155 0.019230328 -0.079404988 0.0900844130 0.0468715167
## 2 0.073139863 0.103115583 0.157496398 -0.0411209659 -0.0237216259
## 3 -0.026651608 -0.008800945 0.026122123 -0.0005591246 0.0985995969
## 4 0.215410640 -0.074546505 0.001237782 0.0358702015 -0.0542694687
## 5 0.346704641 -0.080683672 0.082484919 0.1148425650 -0.1091890982
## 6 0.047075250 -0.055543936 -0.044741956 0.0052529551 -0.1571547597
## 7 -0.026348363 -0.130309544 -0.028586438 0.0703993234 -0.0312596944
## 8 0.106824198 -0.149876698 0.218366384 -0.1624120336 0.1242014435
## 9 -0.065337163 0.219265359 -0.027807931 -0.0036937630 0.2701253693
## 10 0.001165108 0.110842231 -0.040067801 0.1054686383 -0.0633730936
## 11 0.053712906 0.028076802 -0.027941782 0.0145114918 -0.0618966960
## 12 -0.146447138 0.090431767 0.031572100 0.0637023645 -0.2425961995
## 13 0.007874497 -0.006797642 0.018879042 0.0148911033 0.0848508474
## 14 0.103636234 -0.051841299 -0.065009639 0.1024201708 0.0063232379
## 15 -0.004017446 -0.077606412 -0.002504141 -0.1285294368 -0.0179966759
## 16 -0.045409890 -0.084334343 0.034221824 0.0075289632 0.0917958996
## 17 -0.072003659 -0.083154804 0.003143680 0.1089785875 0.0351620314
## 18 0.009829948 -0.019478650 0.019176841 -0.0196747998 -0.0089155022
## 19 0.098811851 -0.055724285 -0.010211266 0.0497963408 -0.1657159014
## 20 -0.090944465 -0.051855242 -0.078969908 -0.0108755242 -0.1531955622
## 21 0.007854600 0.004125242 0.015955425 0.0085720217 0.0160818030
## 22 0.048491595 0.012517099 -0.002874824 -0.0137683154 -0.1191550728
## 23 0.033715952 0.068432870 0.184823794 0.1013360394 -0.0191184177
## 24 0.009432634 -0.086882442 0.079838835 0.0389823120 0.0643607550
## 25 -0.005090121 0.072590459 -0.020521818 -0.0601659316 -0.1761189407
## 26 -0.165917967 0.148948338 0.238186668 0.0915189673 -0.0716599969
## 27 -0.002015654 -0.016172790 0.014334580 0.0048074805 0.1180855256
## 28 -0.029405240 0.024870192 0.023156693 0.0057024672 -0.1040893641
## 29 0.017307188 0.086985608 -0.068255553 -0.0700812334 -0.0930353054
## 30 -0.039355114 -0.173113440 -0.088257014 -0.1471841572 -0.0107528180
## 31 0.022351693 -0.057682357 0.048868819 -0.0404407662 0.0029832057
## 32 -0.024652818 -0.001887881 -0.006444861 0.0435431477 0.1085713625
## 33 0.213936685 0.003773993 -0.136698679 -0.0568271712 0.0828052594
## 34 -0.012383492 0.121307929 0.094591671 -0.0812145923 -0.0300764826
## 35 -0.297229068 -0.333252696 -0.062340115 0.0592579791 0.0077646348
## 36 -0.179009303 -0.159277707 -0.093602476 -0.0212267835 -0.0260751478
## 37 -0.003188370 0.121321656 -0.070934599 -0.0396544720 -0.0693131210
## 38 -0.015185405 -0.010882913 -0.043815697 0.0334263019 0.0766783024
## 39 0.024814688 0.070589384 -0.056706638 0.0035328423 0.0353722013
## 40 0.065550379 -0.011191742 -0.190911383 -0.0260407681 -0.1838061578
## 41 0.007945597 -0.085624864 0.021861651 0.0224510827 0.0435608940
## 42 0.014113108 0.007899839 0.030545371 0.0039479460 0.0036370804
## 43 -0.077482462 0.053566263 -0.028797777 0.1652932715 0.0670744267
## 44 -0.013363310 -0.028736172 0.013722584 0.0247697468 0.0723189675
## 45 -0.018818689 0.044132919 0.118377513 0.0051276598 0.0338289357
## 46 0.074137427 -0.059196483 0.086543502 -0.0288077728 0.0882212633
## 47 0.011082199 0.012151280 -0.010705167 -0.0414518290 -0.0012515169
## 49 0.051812439 -0.224334502 0.156607030 -0.1824798426 -0.0090887191
## 50 -0.017350985 0.007374028 0.002869939 0.0123164187 0.0308682397
## 51 -0.172351526 -0.073409807 -0.023294451 0.0364036741 0.0075836815
## 52 0.087131016 0.057895931 0.085045304 0.0589526882 0.0933470327
## 53 0.050677981 0.016690793 0.007976308 -0.1202879854 -0.0489370655
## 54 -0.013857968 0.011004792 -0.035598608 0.0691920528 0.0101887511
## 56 -0.102175237 0.238678965 -0.184123537 -0.1496164114 0.0937995908
## 57 -0.055357387 0.062765485 -0.079721203 0.1270313491 -0.0008078426
## 58 -0.035938062 0.105636748 -0.028667549 -0.1540293339 -0.0636982742
## 59 -0.035689959 -0.005649551 0.089160000 0.1353251216 -0.0172901535
## 60 -0.066143388 0.077068721 -0.044658238 0.1182241765 0.0152072146
## 61 -0.041085577 -0.024075816 -0.022125649 0.1848486656 0.0719950974
## 62 -0.052534941 -0.023797129 -0.013222026 0.0227348065 -0.0685399489
## 64 -0.018474500 -0.039462601 -0.134717942 -0.1511736185 0.0799818550
## 65 -0.054778964 -0.009443713 -0.054066720 -0.1195143349 0.1016783073
## 66 0.098991413 0.071271648 -0.127496595 0.1145378570 0.0874447682
## 67 -0.020666589 0.001012005 -0.019384346 -0.0196448796 -0.0056015916
## 68 0.031897850 0.140914668 0.031277985 -0.1384195101 -0.0339322900
## 69 -0.108532535 0.067356413 0.086114962 -0.1292853471 -0.0305204322
## 70 0.217866131 -0.013897322 -0.133461921 0.1862210054 0.0888371277
## 71 0.025256659 0.053176396 -0.040381970 -0.1023564000 -0.0886492836
## 72 -0.010825195 0.063060161 0.208610703 -0.1058012852 0.0891561144
## 73 -0.070349521 0.006177537 0.164298681 0.0690040721 -0.0663106117
## 74 0.074755861 -0.035733530 -0.168435904 -0.1644698826 0.0777504919
## Axis.16 Axis.17 Axis.18 Axis.19 Axis.20
## 1 2.019853e-02 -0.0268093276 0.0438216534 0.030051161 0.020640065
## 2 -1.408200e-01 -0.1776961743 -0.0303958232 0.045098591 -0.020511778
## 3 9.307787e-02 -0.0874745429 -0.1847217294 -0.143001893 0.104735054
## 4 4.180861e-02 -0.1323901312 -0.0009695049 -0.209352875 -0.148435017
## 5 -5.310892e-02 -0.0723333754 -0.0756289437 0.122137978 -0.103947580
## 6 6.776792e-02 -0.1715817104 0.1573190293 0.013716530 0.075504675
## 7 1.125191e-02 0.0255424905 0.0319915715 0.092235936 0.011911298
## 8 2.232769e-02 0.1799751648 0.1532016533 0.023222591 0.090297127
## 9 -1.282132e-01 0.1419941379 0.2076126749 -0.065235348 0.088712530
## 10 1.261276e-01 -0.0700844894 0.1076290221 -0.081152906 0.096840557
## 11 -1.827529e-02 0.0533207604 -0.0192589971 -0.049400125 -0.048157767
## 12 1.975939e-01 0.1228442870 -0.1533094179 0.016424753 -0.008882459
## 13 4.125259e-02 0.0167080864 0.0052215959 0.093568577 -0.015783863
## 14 1.216709e-01 0.1587072189 0.0881081492 -0.043287662 0.031903080
## 15 -7.962604e-02 0.1600181225 -0.0672895254 0.153008131 -0.143187371
## 16 6.175780e-02 -0.0264154907 -0.0423826372 0.003905794 0.119026160
## 17 -2.573265e-02 0.0414277704 -0.0632910177 0.025144100 -0.104137106
## 18 1.310978e-02 -0.0248563856 -0.0122302225 0.065119253 0.075567471
## 19 -2.027314e-02 -0.0878952567 0.2067991944 0.188474192 0.060919606
## 20 5.805353e-04 0.0562880234 0.1614785999 0.044555498 0.045885402
## 21 2.155568e-02 -0.0424571815 -0.0378752657 0.007165313 0.071223478
## 22 -5.126884e-02 -0.0553022507 -0.0146642870 -0.033322013 -0.005451525
## 23 1.264818e-01 0.1032328781 0.0388824333 -0.044275165 -0.040971903
## 24 1.183083e-01 -0.0333526798 -0.1087123777 0.054829268 0.109792742
## 25 -6.143846e-02 0.0312186859 0.0403098299 -0.103780829 -0.036797444
## 26 -2.408280e-01 0.0135356492 -0.1104104499 -0.036625602 0.030762633
## 27 5.284162e-02 -0.0019800740 -0.0366177487 0.049637898 -0.004982663
## 28 -1.095933e-02 -0.0863540504 -0.0238858313 -0.135257180 0.049180128
## 29 -9.099189e-02 0.0215552452 0.0821777310 -0.075574267 -0.074047227
## 30 8.722258e-03 -0.0422037079 -0.0367864806 -0.092837205 0.113003278
## 31 3.553917e-02 0.0012171603 -0.0140991777 0.046740963 0.069524278
## 32 -2.042322e-02 0.0824303424 -0.0337044055 0.014109525 -0.078975677
## 33 5.046905e-02 -0.0230206351 0.0147294169 0.050918899 -0.106761550
## 34 -2.603700e-02 -0.0336909082 0.0013948250 0.065069132 -0.035126420
## 35 -1.352788e-01 0.0108822667 0.0529206519 -0.077328280 0.003036764
## 36 -1.657989e-01 -0.0925196899 -0.0647858412 0.112165737 -0.138906655
## 37 -5.483633e-02 0.0824539938 0.0341054800 -0.033514133 0.009726249
## 38 1.824934e-02 -0.0791984468 0.0016476308 0.028776536 -0.028802450
## 39 -5.762957e-02 0.0130592027 0.1112555056 0.138370330 -0.002056459
## 40 8.248997e-02 0.2757067024 -0.1885995477 0.055591206 0.061315689
## 41 2.389350e-02 0.0497061233 0.0001552184 -0.031623530 -0.093281452
## 42 4.449997e-03 0.0126905570 -0.0106132025 0.029273067 0.056420703
## 43 5.013761e-02 -0.0863850116 -0.0805357636 0.082077215 0.054528757
## 44 4.730889e-02 -0.0552799958 0.0250728407 -0.019049230 -0.052769575
## 45 -2.206050e-02 -0.0002086793 0.0034198774 0.059745351 0.037536866
## 46 4.065301e-02 0.0519332327 -0.0210563696 0.104894940 -0.010856447
## 47 -9.846077e-03 0.0067937255 0.0206442160 -0.007753691 0.009924196
## 49 8.504089e-02 0.0204485638 0.0262094464 -0.107120477 -0.058374833
## 50 -5.993210e-03 0.0123031870 -0.0015715474 0.065436020 -0.018691113
## 51 1.049801e-01 0.1001576841 0.1317561780 -0.073895867 0.030298697
## 52 -4.568327e-02 0.0498329167 -0.0509584341 -0.012778674 -0.127910871
## 53 -7.096287e-02 0.0665694856 0.0890398312 -0.049417625 -0.035726607
## 54 -7.920405e-02 0.0690852399 -0.0049789395 -0.168845653 -0.166211503
## 56 1.793786e-01 -0.0351446468 0.0406115560 0.053029792 -0.191916529
## 57 -6.192696e-02 -0.0235838641 0.0401744388 0.190363243 0.015522703
## 58 -4.226254e-05 -0.0808672652 -0.0067906121 -0.052714331 0.127779701
## 59 5.728809e-02 -0.0527904140 0.0169179442 -0.063740476 0.021626786
## 60 1.193038e-03 -0.0642457511 -0.0306953349 0.061983331 0.005416016
## 61 2.682820e-02 0.0058070133 -0.0536759007 -0.165409700 -0.209282724
## 62 3.057572e-02 -0.0345254921 -0.0238637021 -0.078381817 0.049814748
## 64 -4.688108e-02 -0.0005850566 -0.0998799514 0.025398741 0.060853504
## 65 1.082405e-01 -0.2905305500 0.0703597283 -0.036903157 -0.060312496
## 66 1.299963e-01 0.0363550365 -0.0242318437 0.012832893 0.041353284
## 67 -2.983668e-02 -0.0258760142 0.0225213008 0.027652633 0.014552000
## 68 5.121771e-02 0.0360189399 -0.1646484551 -0.062704172 0.122093985
## 69 -5.741576e-02 -0.0529105962 -0.0836496756 0.079734215 -0.063229201
## 70 -2.959803e-01 0.0282411839 -0.0264693668 -0.130730173 0.215703218
## 71 -7.974857e-02 0.0392971637 0.0997435469 -0.093077607 -0.062214005
## 72 2.099744e-02 0.0147445820 0.0356662730 -0.044294099 0.008739066
## 73 1.897578e-03 0.0060340814 0.0284220729 0.080178633 0.020578940
## 74 -1.101388e-01 -0.0275870598 -0.1880827864 0.009747794 0.064448835
## Axis.21 Axis.22 Axis.23 Axis.24 Axis.25
## 1 -0.019813434 -6.018183e-02 0.0017887689 0.052709180 -0.0122146637
## 2 0.030744025 -7.388235e-02 -0.0078717853 0.040900503 -0.0942251481
## 3 -0.097290396 3.487081e-02 0.2965272647 -0.100263298 -0.1761808235
## 4 0.103715827 5.704450e-02 -0.0033419521 0.239868475 0.1544359992
## 5 -0.215474253 9.377301e-02 0.0914557029 -0.008210011 0.1242374868
## 6 0.078729731 -8.509345e-02 -0.1194291354 -0.100283973 -0.0147808443
## 7 -0.136953118 -8.193977e-02 -0.0755474215 -0.020848448 -0.0963297858
## 8 0.049096084 -1.445831e-01 -0.0012023981 0.142439656 -0.1478691125
## 9 -0.001771771 1.500172e-01 0.0706042826 0.053592496 0.1803192378
## 10 0.065133319 -4.524240e-02 -0.0035655907 -0.021582580 0.0153207745
## 11 -0.059503626 1.026420e-01 -0.0320531829 -0.008592223 -0.0257326942
## 12 0.031966668 -1.318400e-01 0.0370137325 0.115890168 0.0915954887
## 13 0.007392605 6.851823e-03 -0.1383818237 -0.009229282 0.0455220577
## 14 -0.054601340 -3.366982e-02 0.0498941614 0.052036923 -0.0443569600
## 15 0.008492503 -1.354654e-02 0.0500014534 -0.163934224 0.0332895435
## 16 0.106000982 -6.987058e-02 0.1476661583 0.056702097 0.0181932748
## 17 -0.010344966 2.385921e-02 -0.0162634977 0.052390935 -0.0430703258
## 18 0.021133456 6.392840e-02 -0.0451894804 0.043368924 0.0158845234
## 19 0.129412059 6.109242e-02 0.1516586657 -0.001429051 -0.0746786889
## 20 -0.262452497 7.144069e-02 0.0929663201 0.011686634 0.0502913566
## 21 0.034668929 4.264894e-02 0.0653123392 0.011730151 -0.0220934275
## 22 -0.022468828 9.117024e-02 -0.0301543508 -0.035168757 -0.0713307841
## 23 0.057565388 1.132549e-01 -0.0250602375 -0.169784270 0.0962619380
## 24 0.012080399 2.318828e-01 -0.0882460598 0.085856769 -0.0647907030
## 25 0.014562396 1.319101e-01 0.0018963641 0.003979397 -0.0458310434
## 26 -0.235280951 -5.317609e-02 -0.0806852149 0.033321837 -0.0501833357
## 27 -0.097570513 4.636303e-03 0.0362668778 -0.044883793 -0.0289878735
## 28 0.029237136 5.140700e-02 0.0022681825 0.039378334 -0.0276211490
## 29 -0.019996945 -1.027085e-01 0.0431911095 -0.042682091 0.0142261557
## 30 0.047649908 2.909005e-02 -0.1450776994 -0.070680498 0.0792354517
## 31 0.001905959 1.048708e-01 -0.0647591265 0.041821009 -0.0331416897
## 32 -0.023457635 -6.682023e-02 -0.0075880770 -0.017453866 -0.0008738851
## 33 0.011968690 -7.174158e-02 0.0348687403 0.061634178 -0.1094586259
## 34 0.142427542 3.398377e-02 0.0474063586 0.001628360 -0.0441512178
## 35 0.047426779 5.628555e-02 0.0218338796 0.007448857 -0.0130766673
## 36 0.107582988 -1.044797e-02 -0.0219706241 0.064117823 -0.0594996961
## 37 -0.081732214 1.718373e-01 -0.1619810222 0.050613990 -0.1959013809
## 38 -0.023547794 -7.836932e-02 0.0557811178 -0.060822510 0.0383394455
## 39 -0.014461496 2.938287e-02 -0.0138882425 0.117028061 0.0233995607
## 40 0.054840323 1.621346e-02 0.0035972906 -0.066278153 0.0418277149
## 41 -0.021283863 3.588623e-02 -0.0961410992 0.027890058 -0.0469902229
## 42 0.019674095 3.461839e-02 0.0095959868 0.034871652 -0.0496280474
## 43 0.031570007 1.649976e-02 0.0281892535 -0.002689484 0.0691250844
## 44 -0.051167680 -7.253776e-02 -0.0320682862 -0.069357469 0.1314938232
## 45 0.100773928 4.607994e-03 0.0778034476 -0.121494727 -0.0602006085
## 46 -0.023124522 7.548814e-03 -0.0424145473 -0.005306960 0.0398197775
## 47 -0.010752978 -5.686196e-02 0.0443441983 -0.018858367 -0.0033330482
## 49 0.019195343 3.643153e-02 -0.0661011799 -0.139272769 0.1027226228
## 50 0.022658643 -2.698649e-02 -0.0324310657 0.003714319 0.0557573163
## 51 -0.062078429 2.181088e-02 0.0489909823 0.059197802 -0.0093263154
## 52 0.071381025 7.645355e-02 0.0356733865 0.060697864 -0.0268894101
## 53 -0.025987028 -1.366442e-01 0.0788166441 -0.039694104 -0.0216591632
## 54 0.026546364 -6.119697e-03 0.0031388144 0.038840857 -0.0167650692
## 56 0.097015534 1.138086e-01 -0.0271111036 -0.096917076 -0.1572118459
## 57 0.052893007 -6.848853e-02 -0.1495248819 0.081224218 0.0931477525
## 58 -0.032176482 -2.499876e-05 0.0913053383 0.105732668 0.1258473751
## 59 -0.006857013 -1.383035e-01 -0.0700368008 0.024051682 -0.1117400000
## 60 0.049926374 -2.743267e-02 -0.0005289627 -0.019660550 0.1025356991
## 61 0.076539428 -6.774975e-02 0.0103745940 -0.028175601 -0.0103002587
## 62 0.040966970 5.264833e-02 0.0428983026 0.047999956 -0.0060870733
## 64 -0.047333032 2.377354e-02 0.0023952500 -0.007049774 0.1281155881
## 65 -0.223871480 -2.510752e-03 -0.0837413971 -0.090708258 0.0118538228
## 66 -0.135743147 -9.300205e-02 -0.0293409557 -0.029736780 -0.0424280234
## 67 0.021100451 -6.494324e-02 0.0416093081 -0.020951109 0.0479058556
## 68 0.033151097 -1.196013e-01 -0.1944161704 -0.008376072 -0.0058584104
## 69 0.030481963 3.191150e-02 0.0897272758 -0.055546410 0.0831019424
## 70 0.109388100 -2.432129e-03 -0.0694486789 -0.220249741 -0.0164744864
## 71 -0.016233350 -1.273643e-01 0.0320735183 -0.026277009 0.0100887442
## 72 -0.007501450 -3.106195e-02 -0.0681338562 0.041302114 0.0814714265
## 73 0.057108102 -2.625408e-03 0.0484926061 -0.116682863 -0.0045794412
## 74 -0.013271899 -6.228887e-02 0.0562682307 0.153464202 -0.0195148904
## Axis.26 Axis.27 Axis.28 Axis.29 Axis.30
## 1 -0.018709256 0.010773843 -0.0275220225 -0.0616787912 1.204348e-02
## 2 -0.020090870 -0.098346321 0.0028276595 0.0145779325 -8.655134e-03
## 3 0.029992851 0.046596238 -0.0942111048 -0.0979890204 1.380443e-01
## 4 0.140302064 -0.015563910 0.0067812860 -0.0503182808 -4.803457e-02
## 5 -0.134607905 0.193780569 -0.0081220327 0.1134740726 7.867665e-02
## 6 -0.171942982 0.127178622 -0.0107162810 0.0476039530 4.442240e-02
## 7 -0.020605776 -0.019998978 -0.1448848379 -0.0320914470 -8.277695e-02
## 8 -0.045598391 0.046671651 0.1039234943 0.1337582266 -3.010557e-02
## 9 -0.106721475 0.155233232 -0.0855596981 -0.0527949734 -1.749331e-03
## 10 0.020901162 0.093847780 0.1814475727 -0.2572708435 -7.165252e-02
## 11 -0.014823199 0.030242403 0.0061714966 -0.0009742044 4.297780e-02
## 12 -0.049478505 -0.185550202 -0.0356087813 0.0803353491 1.017189e-01
## 13 0.023223149 -0.021328169 0.0219319552 -0.0178324682 2.338986e-02
## 14 -0.023723809 -0.059346121 0.0683305318 -0.0626871159 1.950055e-02
## 15 0.095084908 -0.016493835 0.1561589768 -0.1567781688 2.075679e-02
## 16 -0.028084038 0.079587559 -0.0187815412 0.1194785813 -1.454488e-01
## 17 0.020238020 0.056805648 0.1648586958 0.0214882564 -2.803819e-02
## 18 0.028098793 -0.004795806 0.0274201850 0.0353805446 -6.905851e-03
## 19 0.034548161 -0.155098158 -0.0912540084 -0.1217795782 -1.636423e-02
## 20 0.299513368 0.059171955 -0.0751426371 0.1266416951 -7.299335e-02
## 21 -0.025714979 0.023893569 -0.0179050172 0.0535332103 -5.983651e-02
## 22 -0.034641788 0.026206432 0.0153484753 0.0055586994 2.938156e-02
## 23 -0.034852603 -0.065341571 -0.0844886810 0.0790887948 -4.884073e-02
## 24 0.004801325 -0.040167971 0.0100879976 -0.0546571186 2.182177e-02
## 25 -0.041038938 -0.051338306 0.0138599294 0.0004346440 -2.469659e-02
## 26 0.006544446 0.020195852 0.0178089091 -0.0604948656 -1.776010e-01
## 27 0.029228662 0.002117047 0.0115912945 -0.0648078172 4.818759e-02
## 28 -0.020361708 -0.007890182 -0.0259811511 0.0127349627 -1.361110e-05
## 29 -0.004335436 0.005690065 0.0061028943 0.0121390669 1.226787e-02
## 30 0.096712068 0.136376775 -0.0403627144 -0.0321062189 -1.445532e-01
## 31 0.018391873 -0.022139698 -0.0024947561 -0.0145087835 5.049474e-03
## 32 0.051596037 0.012935772 0.0005206341 -0.0257676080 -2.735048e-02
## 33 -0.004180071 -0.025663703 -0.0388144375 -0.0317009796 -9.964320e-02
## 34 0.024924652 0.026402691 0.0246732258 0.0757493290 9.668114e-02
## 35 -0.152070003 0.016182369 0.0958219467 0.0387454197 1.486068e-01
## 36 0.063032634 0.125310129 -0.1366119284 0.0150933520 1.329569e-01
## 37 -0.049630992 -0.032813878 0.0170725590 -0.0188488648 4.121600e-02
## 38 0.004943059 -0.040133327 -0.0121753829 -0.0480057530 -9.431405e-03
## 39 -0.135316265 -0.006042666 -0.1353359211 -0.1603211348 4.671637e-02
## 40 -0.056440638 0.118755271 0.0584104700 0.0019286683 -2.219968e-02
## 41 -0.039782008 -0.047382903 -0.0243650896 -0.0695631393 -1.190119e-02
## 42 -0.011044186 0.002473138 -0.0024794311 0.0415348944 5.262959e-04
## 43 0.020378461 0.031316509 0.0216279557 0.0219103359 -2.336276e-02
## 44 0.076489509 -0.005654194 -0.0758835496 -0.0590840009 1.858855e-01
## 45 -0.012273980 0.040340507 0.0254160553 0.0104009209 -3.871558e-02
## 46 0.057783389 -0.044370089 0.0518066026 -0.0940560179 7.918046e-02
## 47 0.020798575 0.021776067 -0.0158427747 0.0283023739 -3.210621e-03
## 49 0.017155005 -0.037924861 -0.0572923176 -0.0322862258 -6.784928e-02
## 50 0.037534534 -0.021636172 0.0275191857 -0.0327877279 -1.043774e-03
## 51 0.009483688 -0.113479123 0.0294247562 0.0330597741 3.144978e-02
## 52 0.086408561 0.034854619 0.0692887315 0.0695182204 -6.220342e-05
## 53 -0.012891093 0.016102708 -0.0079998144 0.0021837562 4.335477e-02
## 54 -0.013095217 -0.046743930 -0.0074406432 -0.0121406239 -2.160698e-02
## 56 0.097277875 0.048294457 -0.0216653259 0.1361690463 -2.528487e-02
## 57 0.040903030 -0.017553204 0.0463826758 0.0714434472 2.202871e-03
## 58 0.049020779 -0.001095147 0.2067704566 -0.0218177230 1.347033e-01
## 59 0.203290863 0.075331451 -0.0710767581 -0.0479711474 2.589188e-02
## 60 0.023728377 0.018068448 0.0470242413 0.0510643982 -4.776310e-02
## 61 -0.138855087 0.018330825 -0.0468034798 -0.0138120968 -6.280188e-02
## 62 -0.021821564 -0.009457277 -0.0588094242 0.0646843278 -8.214288e-02
## 64 -0.090103167 -0.199796964 -0.1598839654 -0.0075740819 -8.012524e-02
## 65 -0.110180389 -0.096363729 0.1941619810 0.0723862963 -2.330405e-02
## 66 -0.060622910 -0.038384249 0.0032323809 0.1205453806 1.656725e-02
## 67 0.008312443 0.032804150 -0.0153443771 0.0589329416 -4.295209e-02
## 68 -0.024964456 0.127515120 -0.1045698557 -0.0743530711 9.209255e-02
## 69 -0.046492599 -0.088124735 0.0282115980 -0.0287213829 -9.285585e-02
## 70 0.124959257 -0.180509101 0.0448482776 0.1152940992 7.442422e-02
## 71 -0.022041472 0.009775431 -0.0163945722 0.0002775521 1.014946e-02
## 72 0.045285856 -0.043398479 -0.0890755101 0.0865415998 1.504024e-01
## 73 -0.077668862 0.007526349 0.0243219555 -0.0472290207 -7.651872e-02
## 74 -0.036080817 -0.038538289 0.0297127807 -0.0071838279 -8.285490e-02
## Axis.31 Axis.32 Axis.33 Axis.34 Axis.35
## 1 1.152015e-02 -0.030640810 -0.0353954497 0.025586046 -0.1240083711
## 2 1.049673e-01 0.018659297 0.0114326910 0.152176363 0.0431630920
## 3 -1.009474e-03 -0.054411427 0.0452303691 -0.034409291 -0.0383577713
## 4 9.078479e-02 -0.082086770 -0.0719075969 -0.060194110 -0.0476839261
## 5 -1.053053e-01 0.042239180 -0.0445996849 -0.056809592 -0.0535773746
## 6 1.399907e-01 -0.178159451 0.2339564626 -0.010995272 0.0085881443
## 7 3.883990e-02 -0.038456835 -0.0679443406 -0.098728890 0.0485739021
## 8 -9.492394e-02 -0.004363892 -0.0081823905 0.003234283 0.0028670483
## 9 1.554287e-01 0.156425154 0.0332250707 -0.046663736 0.0832755259
## 10 -1.368900e-01 -0.056822808 0.0270074038 -0.032481916 0.0298083735
## 11 -5.322671e-03 -0.010756897 -0.0018293703 0.016978066 0.0560776921
## 12 1.623270e-02 0.134237577 0.1241837648 -0.055272020 -0.0473486172
## 13 3.733322e-02 -0.027071194 -0.0135177030 0.003742949 -0.0075140421
## 14 3.768546e-02 -0.057218543 -0.0051086084 0.080399338 -0.0441260180
## 15 5.072655e-02 -0.018574000 0.0839880207 -0.094466203 -0.0901070151
## 16 -5.659609e-02 -0.065188408 -0.0136441044 -0.082509006 -0.0319045978
## 17 -2.972691e-03 -0.047274205 0.0607823969 -0.011151141 0.0214755907
## 18 2.105458e-02 -0.014416398 0.0014710819 0.001311999 0.0044225290
## 19 -1.193023e-01 0.177733413 -0.1792466751 0.016412989 0.0003000862
## 20 1.044440e-01 -0.014732185 0.0242818407 0.041822879 -0.0408134088
## 21 -1.747514e-02 -0.012128261 -0.0073045727 -0.012081326 -0.0451942855
## 22 1.533919e-02 0.060136861 0.0080723562 0.059031790 0.0994937204
## 23 6.746058e-02 -0.192897444 -0.1214253280 0.014858265 -0.0086562470
## 24 4.546427e-02 -0.005502978 0.0120825261 -0.010993502 0.0078636421
## 25 4.418669e-02 0.007677591 0.0539483709 -0.037596962 0.0807214843
## 26 -9.426954e-02 -0.109253338 -0.0549440959 0.056125041 -0.0003495194
## 27 -2.564446e-03 0.016759118 0.0180914664 0.006915296 -0.0157073285
## 28 1.801376e-03 0.009867786 0.0098693825 0.035183650 0.0160455996
## 29 -1.023055e-02 0.010955125 0.0041455628 0.003755755 0.0177778016
## 30 -1.469161e-01 0.189947330 0.0804397598 0.039219929 -0.1448385485
## 31 2.581139e-02 -0.011957994 0.0151232326 -0.006168155 0.0074115220
## 32 6.560684e-03 -0.058068219 -0.0406203703 -0.003468353 0.0609003033
## 33 1.593910e-01 0.006323793 0.0178745993 0.018865240 -0.0166178158
## 34 -2.659944e-02 0.004949513 0.0017503305 -0.017114772 0.0134467059
## 35 1.053653e-01 -0.001551467 -0.1577215710 0.182170709 -0.1092047091
## 36 -5.482452e-02 -0.035443879 0.0457932417 -0.091333186 0.1065964458
## 37 -2.698759e-02 0.053932538 0.0495013319 -0.053930288 -0.0756374422
## 38 6.746858e-02 0.035220322 0.0081183850 0.053853161 0.0243220818
## 39 -1.539664e-01 -0.150167358 0.0717452370 0.045233382 -0.0951464741
## 40 -3.490250e-02 0.002021339 -0.0937108187 0.036930663 0.1656205855
## 41 -5.900942e-03 0.036329391 0.0056434486 -0.017875246 0.0387155580
## 42 1.514445e-05 0.010292901 0.0029724774 -0.010687346 -0.0033209885
## 43 4.455006e-03 -0.008641546 -0.0239852767 0.039068627 -0.0142940069
## 44 -3.920847e-02 -0.002334126 -0.0171487772 -0.015025963 0.0582682975
## 45 3.788208e-02 0.085972642 0.0133624964 0.008370682 0.0489453378
## 46 1.974000e-02 -0.008567105 -0.0008636556 0.044771253 0.0307097778
## 47 -2.587391e-03 -0.026581471 -0.0039629085 -0.013445845 -0.0258304758
## 49 -1.300482e-02 0.016174587 0.0128960778 0.118018923 0.0759841367
## 50 1.613941e-02 0.016185628 0.0064230173 0.002013694 0.0240935789
## 51 -3.856907e-02 -0.039918725 0.0280371324 -0.194598728 0.0077201229
## 52 -3.600407e-02 0.071282402 0.2092306361 0.057189466 -0.0983845516
## 53 -1.466449e-02 -0.024816835 -0.0106907715 -0.019159323 -0.0753032218
## 54 -2.092145e-02 0.041050888 -0.0355070308 -0.013122672 -0.0157065677
## 56 -9.014488e-02 -0.103237628 -0.1139221417 0.061021250 -0.0198645350
## 57 -7.151915e-03 0.016678076 -0.0386150039 -0.024987495 -0.0327112385
## 58 -6.446170e-02 -0.068204683 -0.0392286289 0.129171030 0.0745587679
## 59 5.602655e-02 0.091868121 0.0474918346 0.056803072 0.1067231664
## 60 5.580660e-04 0.014529642 -0.0067617470 0.021506832 0.0325099400
## 61 -1.143308e-01 0.075454858 -0.0096376499 0.017707392 0.0187283343
## 62 -1.108892e-02 -0.011826694 0.0115456309 -0.042000688 -0.0287553301
## 64 -1.098478e-01 -0.078947342 0.1377937626 0.100117604 0.0666127753
## 65 -2.529792e-02 0.106343648 -0.0632781471 -0.159678775 0.0258568618
## 66 5.825928e-03 0.115098664 0.0379869504 0.170317384 -0.0179064698
## 67 -2.378292e-02 -0.013335583 -0.0042187451 0.013801077 0.0160890425
## 68 1.068042e-01 0.046505601 -0.1804165244 -0.066201712 -0.1747119786
## 69 8.944925e-02 0.005865975 0.0128100017 -0.007577653 -0.1905734543
## 70 -4.068138e-02 -0.050704669 0.0098593336 -0.095758747 -0.0391808120
## 71 7.988522e-04 0.003292857 -0.0230558184 0.004160949 -0.0194800891
## 72 -1.096048e-01 -0.002679221 -0.0284793099 -0.051894715 0.0635468310
## 73 7.473634e-02 0.058132380 0.0101117138 -0.100625605 0.0727806125
## 74 9.802450e-02 -0.021203808 -0.0714045815 -0.088838793 0.1322222144
## Axis.36 Axis.37 Axis.38 Axis.39 Axis.40
## 1 0.0604984456 -0.0404561380 0.0053185878 0.0024882973 -9.748137e-02
## 2 0.1613183084 -0.0745883067 -0.0189305532 0.1173288020 -1.292649e-02
## 3 0.0405688915 -0.0074150708 0.0638403528 0.0453634716 -5.546280e-02
## 4 -0.0495847244 0.0341212262 0.1425391660 0.0559035078 -4.870707e-02
## 5 -0.0748075471 0.0456019598 -0.0284366422 -0.0240470443 5.827465e-03
## 6 -0.0455230001 0.0007108488 -0.0024390717 -0.0014871198 -5.569763e-02
## 7 -0.0076831207 0.1305883725 -0.0628739811 0.0992689370 -8.867239e-02
## 8 -0.0178511511 0.0316407089 0.0917073294 0.0107501485 2.913880e-02
## 9 0.0709014724 0.0407674351 0.0059272137 0.0280048066 -4.783696e-03
## 10 -0.1292293565 -0.0822894412 -0.0049526809 0.0721604802 1.132751e-01
## 11 0.0268342358 -0.0088107194 0.0182604594 -0.0266553219 -2.969113e-02
## 12 0.0476734780 -0.0366909504 -0.0305358918 0.0217531598 -4.408833e-02
## 13 -0.0044589180 0.0026473317 0.0388228523 0.0033876089 -2.539275e-03
## 14 0.0244848846 -0.0837125877 -0.0483424058 0.0766788676 -1.233793e-02
## 15 -0.0186893809 0.1451015279 0.0070471806 0.0668283063 1.160421e-01
## 16 0.0538149472 0.0183599477 -0.0185058444 0.0187919130 1.666972e-02
## 17 0.1523430105 0.0553998174 0.1876802136 -0.1758427562 1.427312e-02
## 18 -0.0064860826 -0.0155857770 0.0006658710 0.0059754697 1.292979e-02
## 19 0.0320898648 0.0313429863 0.0294849499 -0.0035112721 2.369287e-02
## 20 -0.0049023078 -0.1155750213 0.0362366299 -0.0099967163 1.038540e-01
## 21 0.0063397478 0.0086222091 -0.0404975157 0.0198146246 9.301231e-02
## 22 -0.0115796119 -0.0118562796 0.0215780340 -0.0044966233 -1.493185e-02
## 23 0.0874744672 0.1087637890 -0.0444135740 0.1484787156 1.512549e-02
## 24 0.0052127747 0.0066557766 0.0003563850 -0.0554842180 -1.550490e-02
## 25 -0.0227055275 0.0288095471 -0.0010371563 -0.0968755110 2.254002e-02
## 26 -0.0242544834 -0.0533401120 0.0229425558 -0.0355633133 -7.900829e-02
## 27 0.0039377191 -0.0348619547 -0.0194615143 0.0332143454 -4.269359e-02
## 28 -0.0439736945 -0.0060210596 0.0252801683 -0.0118636438 2.399277e-02
## 29 -0.0086078214 0.0088747742 0.0074177965 0.0019967501 -7.456636e-03
## 30 0.0589058893 0.0486887294 -0.0045905251 0.0255350240 -2.003390e-01
## 31 -0.0049285918 -0.0132860589 -0.0087673089 0.0005923822 -7.127522e-03
## 32 0.0690837165 0.0058396758 -0.0704160565 0.0020716981 -1.444783e-02
## 33 0.0681295675 -0.0582573669 0.0235508730 -0.1184219265 -3.358642e-02
## 34 0.0185848923 -0.0176249260 0.0354078999 -0.0726973222 -6.222790e-03
## 35 -0.1146398434 -0.0369861448 0.0034390991 0.0215715476 3.871153e-02
## 36 0.0979549897 0.0026753888 -0.0197974949 0.0850432651 4.428018e-02
## 37 -0.0359282801 0.0623597511 0.0014804799 0.1207226953 1.553520e-02
## 38 -0.0208471775 0.0035678416 0.0585393180 -0.0291315017 -3.029953e-02
## 39 0.0708165749 -0.0486556675 -0.1072498818 -0.1442888962 5.582812e-02
## 40 0.0723550171 -0.1314623878 0.0307217281 0.0193910600 -1.801759e-02
## 41 -0.0158158029 0.0304545386 -0.0139656884 0.0209736212 -3.026802e-02
## 42 0.0079112410 0.0032962715 -0.0075641522 0.0085267950 3.853617e-02
## 43 0.0110179084 -0.0306957499 0.0032699814 -0.0078996740 1.173918e-02
## 44 -0.0824490947 -0.0762305738 0.0142848166 -0.0230402587 -7.612881e-02
## 45 -0.1123809918 -0.0875229628 0.0427960195 0.0273171345 -5.281429e-02
## 46 -0.0188627595 -0.0321675621 0.0206146406 -0.0195573665 -4.900371e-02
## 47 0.0159792297 0.0005176019 0.0065386539 0.0150037160 1.478898e-02
## 49 0.0657550097 -0.0772371010 -0.1637501494 -0.1003502725 4.587480e-02
## 50 -0.0146725961 -0.0019601651 -0.0031422652 -0.0245888588 -5.683392e-03
## 51 -0.0053345072 -0.0122211532 -0.0544878440 -0.1038601359 -5.174703e-02
## 52 -0.0261517388 -0.1120530911 -0.1257303311 0.1285707354 2.898050e-02
## 53 0.0074318756 -0.0038087863 0.0418352872 0.0472911075 -5.185982e-02
## 54 -0.0006669631 -0.0492162453 0.0105659498 0.0121157844 -2.956024e-02
## 56 -0.0957918143 0.0142190981 -0.0053611910 -0.0311515667 -7.325245e-02
## 57 -0.0212410651 -0.0181234395 0.0116583220 0.0759300631 -5.447762e-02
## 58 0.1153289588 0.2239442060 -0.0869749686 0.0092300933 -7.510575e-02
## 59 -0.0467576020 0.1614387909 -0.0699549596 -0.0542832192 1.373894e-01
## 60 -0.0076870651 0.0139463953 -0.0095362117 -0.0270593281 4.009710e-02
## 61 0.0132727623 0.0480416866 -0.0177519570 -0.0185097318 7.661487e-02
## 62 0.0152865578 0.0270608572 -0.0494836811 -0.0261935801 4.772654e-02
## 64 -0.0646962225 0.0304389275 0.2353589351 0.0892104120 1.144384e-01
## 65 0.1402736103 -0.0902442695 0.0001648168 0.0582045914 9.591222e-02
## 66 -0.0929648517 0.1513386683 0.0161297403 -0.0530314706 1.779833e-02
## 67 0.0068508391 -0.0202701648 -0.0244573657 0.0174458470 5.085339e-02
## 68 0.0507205848 -0.0337526698 0.0560989305 -0.0513501572 1.580334e-01
## 69 -0.0997960709 0.0546333942 -0.0670578099 -0.1068233855 -1.083906e-02
## 70 0.0350865513 -0.0153088833 -0.0316581601 -0.0805503656 1.683891e-05
## 71 0.0113955212 0.0154694173 0.0059009089 -0.0219663712 -2.872280e-02
## 72 -0.1287100335 -0.0510069540 0.0276678943 -0.0202142111 -9.420009e-04
## 73 -0.0540254586 0.0095340956 0.0906443311 -0.0362792285 -9.469562e-02
## 74 -0.1909482861 -0.0161778527 -0.1796495382 0.0041365841 -1.640395e-02
## Axis.41 Axis.42 Axis.43 Axis.44 Axis.45
## 1 -0.098619047 6.912920e-02 -0.054455883 -0.0036671470 -0.083596302
## 2 -0.083421499 -9.341857e-02 -0.044290858 -0.1097025153 0.116134148
## 3 0.028522268 2.585276e-02 -0.039285414 -0.0410825880 -0.073322129
## 4 0.064132273 1.705726e-03 -0.056765324 -0.0370450705 0.011544763
## 5 -0.053737219 2.878780e-02 0.026152093 -0.0342619192 0.038093377
## 6 0.026474431 6.589191e-03 0.005241063 -0.0089395884 0.013789802
## 7 0.009460457 7.874235e-02 0.138282128 -0.0384032160 0.083463335
## 8 -0.039714290 -4.311750e-02 0.015300535 0.0250420443 -0.126472045
## 9 -0.022768175 1.473367e-02 -0.002053937 -0.0457595078 0.004854118
## 10 -0.071429290 -5.725994e-03 0.074636251 0.0334021889 -0.031073528
## 11 0.018678911 -6.958234e-02 0.029938385 -0.0159753679 -0.042063246
## 12 0.043332367 -3.107527e-02 -0.023953561 -0.0069562679 -0.007225286
## 13 0.018340745 1.693555e-02 -0.027287730 -0.0500230931 -0.033351387
## 14 -0.040297430 1.190252e-02 0.029671422 -0.1372001675 0.062966100
## 15 0.051299942 -1.501218e-01 -0.025499818 -0.0433256152 0.095363242
## 16 0.022272517 1.104376e-02 -0.024457531 -0.0073304667 0.101115864
## 17 -0.040740136 7.166197e-02 -0.061684583 -0.1081821891 0.018375447
## 18 0.039033870 -3.429381e-03 0.022621854 -0.0582621388 -0.017529984
## 19 0.003521558 8.947287e-04 0.021384372 -0.0078125676 -0.008809901
## 20 -0.016875444 -3.251867e-02 -0.037852282 0.0528325887 -0.014621294
## 21 0.055438027 1.088237e-02 -0.007979885 -0.0191357418 0.025558351
## 22 -0.031713171 -1.704446e-02 0.045816375 -0.0051778293 -0.051265110
## 23 -0.020362779 -1.067120e-01 -0.059257009 0.0886737470 -0.147523656
## 24 -0.119841676 -2.907723e-02 -0.022009850 0.1517986742 0.103973106
## 25 -0.064920933 -6.657377e-02 0.029642276 0.0436428749 0.044379974
## 26 0.031264436 -4.050448e-02 0.029313730 0.0189281172 -0.022200802
## 27 0.033320336 -3.838103e-02 0.022484231 0.0113205511 -0.005643828
## 28 0.013031645 -4.936187e-02 0.025354794 -0.0017930690 0.007993002
## 29 0.032428817 -9.626779e-03 0.021531421 -0.0376626050 -0.038459117
## 30 0.026003545 -1.339718e-01 -0.031846412 0.0006642078 -0.008447706
## 31 0.024144261 1.346571e-02 0.013592453 -0.0605243927 -0.041297689
## 32 0.067170129 3.855913e-02 0.066642328 0.0616192585 0.089273420
## 33 0.172280146 -2.287197e-05 0.129861831 0.1736881025 -0.024731871
## 34 -0.018786769 -4.573104e-02 0.008174924 -0.0181175885 -0.059325384
## 35 0.078526798 -2.411675e-02 0.006164803 0.0382051663 0.029537621
## 36 -0.086261810 -1.832391e-02 0.068820896 0.0525636151 -0.088503932
## 37 0.111827110 1.206339e-01 -0.084312643 0.0043272378 0.004392235
## 38 -0.032747090 -3.680335e-02 0.020923869 0.0428441247 -0.048272794
## 39 0.100423307 -8.425389e-02 -0.146608252 0.0012271322 0.006513826
## 40 0.057361656 7.243203e-02 -0.075396506 0.0410353457 -0.030703793
## 41 0.011899659 2.515415e-02 0.019813796 -0.0225475880 -0.068377902
## 42 0.011470883 1.318434e-02 -0.002763774 0.0039369686 0.012518750
## 43 0.005282525 -3.635095e-02 0.018603163 0.0325132925 0.045322565
## 44 -0.016558748 -7.125859e-03 -0.022696493 -0.0221597150 -0.006311924
## 45 0.051068821 6.422687e-02 -0.037005949 -0.0035054698 0.066451683
## 46 -0.014375070 -7.116526e-03 0.012740001 0.0067178828 -0.034099712
## 47 0.017732885 -7.561058e-03 0.010093239 -0.0067581580 0.009710698
## 49 -0.059128340 1.280851e-01 -0.018288950 -0.0658073178 0.029720312
## 50 -0.037136622 -1.853958e-02 0.029560146 0.0230337273 -0.002059315
## 51 -0.103800838 -4.499786e-02 0.083419819 -0.0490707230 0.015879563
## 52 -0.037725203 5.318396e-02 0.104066088 0.0652180214 -0.017958513
## 53 -0.120986317 8.973445e-02 -0.154427775 0.1589319276 0.113484303
## 54 0.002370581 8.718125e-03 0.022277940 -0.0541938651 0.014431090
## 56 -0.045654608 3.583327e-03 -0.008867372 -0.0800139941 0.070436330
## 57 -0.050416022 9.009246e-02 -0.060074807 0.0121704462 -0.022464001
## 58 0.044230260 8.646912e-02 0.082444622 0.0615902210 0.020353043
## 59 0.034554164 9.164030e-02 -0.149025383 0.0026160942 -0.025889631
## 60 0.017701870 -3.244896e-02 0.035450057 0.0140374121 0.032792323
## 61 -0.014150801 -1.620366e-02 -0.038532179 0.0616827488 0.005025385
## 62 0.006775842 1.812442e-02 0.024626200 -0.0104733990 0.033358852
## 64 -0.057936223 7.536467e-02 0.046723081 0.0041733395 0.019815521
## 65 0.045936912 2.803210e-03 -0.067285564 0.0428814284 -0.035168909
## 66 -0.050590054 -1.029866e-01 0.003520490 -0.0095637240 -0.014150876
## 67 0.128917571 2.754566e-03 0.045217465 -0.1525705529 -0.081536176
## 68 -0.076691101 -4.329204e-03 0.113812771 -0.0312059115 0.030776510
## 69 -0.036432842 1.719687e-01 0.021704946 0.0021508779 -0.132482606
## 70 0.007455890 2.454696e-02 0.002383663 0.0059514257 -0.010471494
## 71 -0.066064391 -2.069246e-02 0.015496466 0.0371368590 0.016173394
## 72 0.153351239 -1.230831e-02 0.011239451 0.0468422983 0.093610396
## 73 0.030264245 -8.758633e-03 -0.036768853 0.0102040261 0.024013083
## 74 -0.067418961 -9.467268e-02 -0.134010862 -0.0293929040 -0.055783688
## Axis.46 Axis.47 Axis.48 Axis.49 Axis.50
## 1 -0.041843991 0.1239305185 -0.100349833 0.045672920 0.0109244156
## 2 0.037499827 -0.0493420752 0.019928905 0.081185105 0.0358999737
## 3 0.015506183 -0.1339975173 0.017540322 -0.012215810 -0.0144476236
## 4 0.006002249 0.0358914266 -0.005720608 0.029565517 -0.0121109598
## 5 0.026115139 -0.0497225083 -0.033018126 0.009429367 0.0339503209
## 6 -0.020334931 0.0157651190 -0.004911027 -0.006956510 0.0006907004
## 7 -0.154355818 0.0148928741 0.046762947 0.010101592 0.0061710605
## 8 -0.038161788 0.0061957274 -0.056877564 0.025963844 0.0167962990
## 9 -0.022402304 0.0074688861 0.019462609 -0.011901929 -0.0009472471
## 10 0.058449110 -0.0245683309 0.033616197 -0.043299793 0.0292896434
## 11 -0.080836357 0.0661482339 0.001040424 -0.008233124 -0.0065975330
## 12 0.005059102 0.0242026367 -0.029546918 -0.004439374 0.0175866343
## 13 0.044333826 -0.0100205881 0.020888130 -0.008430644 0.0205263647
## 14 -0.024327558 0.0662182096 -0.032329856 -0.114622622 -0.1918946340
## 15 -0.025096254 0.0254979544 0.007936727 0.005075668 0.0256341006
## 16 0.075708781 -0.0144061498 -0.061601692 -0.012928630 0.0022983791
## 17 0.005645429 0.0442280008 0.038007480 0.003243200 0.0173055709
## 18 -0.002283069 -0.0280360082 0.026131166 -0.033806275 0.0153635847
## 19 0.005556606 0.0252767181 0.009545996 0.001877345 0.0021136881
## 20 0.044347280 -0.0005946148 -0.014350820 0.046770035 -0.0535543223
## 21 -0.031175773 0.0294053037 0.065456483 -0.019326218 0.0053376863
## 22 -0.090683871 0.0039517343 0.063664567 0.011062685 0.0156256561
## 23 0.025507235 -0.0008320979 0.010329276 -0.015604551 0.0528828485
## 24 -0.020234661 0.0147573793 -0.048868508 -0.038635637 -0.0258443391
## 25 0.003623280 -0.0245328722 -0.085497380 -0.022493601 0.0123334853
## 26 0.028372147 0.0453839255 0.037443668 -0.020436453 -0.0052343366
## 27 -0.029872563 0.1486295120 -0.021958833 0.002339704 0.0491818738
## 28 -0.036014622 -0.0392547669 -0.039995185 0.011326813 -0.0106937104
## 29 0.027746204 -0.0302996572 -0.040319580 0.025759249 -0.0209443308
## 30 -0.021994756 -0.0345737299 0.013343566 -0.025968966 -0.0133678940
## 31 0.024432136 -0.0228459462 -0.032345302 -0.004864683 0.0112604953
## 32 0.061899305 -0.1321397957 -0.099256834 -0.063674356 -0.0571398165
## 33 0.057705591 0.0012081607 0.088498655 -0.007054006 0.0455237016
## 34 -0.059329150 -0.0132152768 0.131442038 -0.140508996 -0.0843049363
## 35 -0.018815742 -0.0450131328 0.016190391 0.025012323 0.0177301739
## 36 0.124091401 0.0861334437 -0.046215421 -0.071616114 -0.0387741629
## 37 0.155595670 0.0442648079 0.048333118 0.004865230 -0.0190687648
## 38 -0.003341869 -0.0327162611 0.002697727 0.018702850 -0.0041592107
## 39 -0.037475964 -0.0522370567 -0.043002155 0.035160907 0.0235545601
## 40 -0.065548372 -0.0228127272 -0.007885266 0.042048474 0.0267298365
## 41 0.045238010 -0.0541512936 -0.051862585 0.068393387 -0.0025538894
## 42 -0.028721087 0.0135502533 0.032640111 -0.017321212 0.0023611709
## 43 -0.076512637 0.0894835216 0.017610657 -0.020946356 0.0527862265
## 44 0.049453637 0.0512957638 0.041172428 0.024165880 0.0262213346
## 45 0.111197808 0.0995385871 -0.107535044 0.015803600 0.1342715133
## 46 0.010694859 -0.0973080121 0.007021305 0.023408852 -0.0294144863
## 47 -0.008610603 0.0439747185 0.039515107 -0.016536850 0.0222140035
## 49 0.086832316 0.0376032575 0.064142511 -0.032372827 0.0070180402
## 50 -0.006485469 -0.0367366281 -0.045139033 -0.005057555 -0.0209973574
## 51 0.034678315 -0.0453219250 0.104086866 0.111527023 0.1154254415
## 52 -0.089734108 -0.0292022319 0.012837368 0.109719415 -0.0051072052
## 53 -0.026063163 0.0023724049 0.145589328 -0.051006837 0.0235409691
## 54 -0.044145448 -0.0647024029 -0.049924263 -0.186226439 0.1540681726
## 56 -0.034647383 -0.0174681865 -0.037357748 0.064635167 -0.0104341161
## 57 0.027772829 -0.1497837845 0.059294441 -0.024225101 -0.0002473885
## 58 0.039704268 0.0358603000 -0.007343811 0.062977394 0.0023611412
## 59 -0.124806665 -0.0376723803 -0.046363829 -0.003026465 0.0496084802
## 60 -0.010744348 -0.0096891864 0.011616088 -0.011968794 -0.0126927671
## 61 0.019401411 0.0539992328 0.073144357 0.121427738 -0.1196613242
## 62 0.035232390 -0.0158896439 0.015686774 -0.019182330 -0.0036180160
## 64 -0.043868497 -0.0130444935 -0.010877409 0.015794864 0.0138047898
## 65 -0.067089292 -0.0101475035 -0.057693721 -0.026412082 -0.0185344904
## 66 0.141753795 0.0132611073 0.016687015 -0.081354095 0.0020395047
## 67 0.008729269 0.0077089314 0.041842804 0.022508501 -0.0004369940
## 68 0.024730455 -0.0051843288 -0.003441100 0.066751126 -0.0017949142
## 69 -0.038645254 0.0175379039 -0.040571929 -0.046884961 -0.0394691276
## 70 -0.007830325 0.0230534935 -0.031599453 0.032588627 -0.0257312307
## 71 -0.024443671 -0.0076000862 -0.126540060 -0.005892143 -0.0121499651
## 72 -0.045307274 0.0417933493 -0.003717806 -0.031125326 -0.0617275694
## 73 0.027649508 -0.0382163547 -0.014968364 0.081000118 -0.1555107953
## 74 0.005519266 0.0327961577 0.037839508 0.010693147 -0.0212663827
## Axis.51 Axis.52 Axis.53 Axis.54 Axis.55
## 1 0.1501974909 -1.001012e-01 0.0211284214 0.1113788322 -5.733398e-02
## 2 0.0045635476 -1.427467e-02 -0.0573862177 0.0164828367 6.498409e-03
## 3 0.0042124066 3.668934e-02 0.0730416348 0.0242076632 -6.423699e-03
## 4 -0.0031743894 -9.049305e-03 -0.0228657363 -0.0404917421 2.583381e-02
## 5 0.0285093470 -3.641312e-02 -0.0255627544 0.0100069790 1.268528e-02
## 6 0.0173041171 -2.216624e-04 -0.0086684988 -0.0062571731 -3.411941e-03
## 7 0.0258004758 7.647397e-02 -0.0058125565 -0.0132409739 -2.315165e-02
## 8 -0.0732927119 -4.775007e-06 -0.0266327423 -0.0468622623 5.211248e-03
## 9 0.0147474137 1.282614e-02 0.0004038222 -0.0023474103 6.408877e-03
## 10 0.0260888953 -1.088854e-02 -0.0193433531 0.0275761002 1.300464e-02
## 11 -0.0261619127 3.025821e-02 0.0333094827 -0.0556942748 -5.211469e-03
## 12 0.0014085950 1.183536e-02 -0.0115507864 -0.0233293016 1.106860e-02
## 13 -0.0543007621 -2.440391e-02 0.0471197318 0.0433201480 3.482007e-02
## 14 -0.0441570921 4.678387e-02 0.0499473796 -0.0419170967 2.113706e-02
## 15 0.0473003871 3.160549e-03 0.0436302410 0.0384850499 -6.088787e-03
## 16 -0.0009081181 6.180622e-02 -0.0868739539 0.0507542272 -1.686195e-02
## 17 0.0104821163 5.165067e-02 0.0377126690 0.0133941757 3.197642e-04
## 18 -0.0188552000 -2.649812e-02 0.0109285904 -0.0361996432 -1.019231e-01
## 19 -0.0088276835 1.177967e-02 0.0090804195 0.0153918366 -1.754387e-03
## 20 0.0147356770 1.132251e-02 -0.0069226377 -0.0159632941 5.238019e-03
## 21 -0.0399801021 1.561489e-02 0.0386959041 0.0199504334 -1.105176e-02
## 22 -0.0300872891 -5.379636e-04 0.0215129011 -0.0683996235 1.560833e-02
## 23 0.0089528761 2.386386e-02 0.0112336289 0.0041024480 -1.233937e-02
## 24 -0.0021738888 4.997799e-02 -0.0126269054 0.0115586504 -4.466506e-02
## 25 -0.0489417046 3.018417e-02 -0.0065812562 0.0428475560 3.383043e-02
## 26 0.0032282909 3.264837e-02 0.0119106294 0.0298006675 -3.080059e-03
## 27 -0.0294390209 -8.172864e-02 -0.0941539064 0.0017670124 1.450263e-01
## 28 0.0557245067 -5.444190e-02 0.0700208065 -0.0846362019 3.789500e-02
## 29 0.0094232540 4.062000e-02 -0.0233135137 0.0069586363 -8.787899e-06
## 30 0.0024709034 1.083069e-02 -0.0061014514 -0.0189200380 7.848804e-03
## 31 0.0024637936 -1.565207e-02 -0.0045534427 0.0293773627 4.809395e-02
## 32 0.0255315622 -8.315057e-02 -0.0995490295 -0.1029733185 7.277551e-02
## 33 0.0101523885 2.468070e-02 0.0273730386 0.0540423367 -1.453681e-02
## 34 0.1602031374 3.638815e-02 -0.1440993520 0.0387960231 6.284896e-02
## 35 0.0139314365 1.013866e-02 -0.0352101550 0.0418547524 8.827145e-03
## 36 -0.0420057607 -4.247590e-02 0.0602408793 -0.0308952797 -1.818065e-02
## 37 0.0158193194 -3.380194e-02 -0.1122962788 -0.0116902906 -7.159572e-02
## 38 -0.0176964850 -5.547484e-02 -0.0075315860 -0.0223808761 8.568081e-03
## 39 -0.0494305321 1.861326e-02 0.0199593620 -0.0480330467 1.109275e-02
## 40 0.0048899763 -8.474127e-03 -0.0324243560 0.0353304206 1.277296e-03
## 41 0.0384571158 4.908826e-02 0.0321452447 0.0601592910 1.656935e-01
## 42 -0.0358031212 8.440025e-03 0.0194066429 0.0451711723 1.177469e-02
## 43 -0.0072269978 -8.607305e-02 -0.0323947930 -0.0589276135 7.999896e-03
## 44 -0.1451820585 1.517518e-01 -0.1258813025 0.0450033134 -3.451124e-02
## 45 0.0738128128 1.078214e-01 0.0779828214 -0.1262871257 1.483058e-02
## 46 0.0859940699 -6.539253e-03 -0.0333627274 -0.1201985103 -1.522334e-01
## 47 -0.0278269861 -2.797598e-02 -0.0238373017 -0.0016428191 -2.722410e-02
## 49 0.0283337213 -4.582237e-02 0.0348432713 0.0371492714 -5.078273e-03
## 50 0.0171481114 4.756614e-02 0.0268218428 0.0212854994 -2.051509e-02
## 51 0.0452726164 -6.075660e-02 -0.0138407934 -0.0389032020 -2.362097e-04
## 52 -0.0414691195 1.592996e-02 0.0188763216 0.0613511396 -2.473937e-02
## 53 -0.0457257498 -4.693469e-02 0.0533086432 -0.0613377050 5.311564e-02
## 54 -0.0759320901 -7.229859e-02 0.0083401296 0.0356552374 -8.422313e-02
## 56 -0.0326999878 -1.886419e-02 0.0096848029 0.0005316157 4.157995e-04
## 57 0.0103677722 5.053401e-02 0.0969389057 0.0091700728 6.190372e-02
## 58 -0.0320625468 -1.710366e-03 0.0367434821 0.0072943662 -5.069055e-03
## 59 -0.0001159500 -1.659592e-02 -0.0458674146 0.0143047463 -2.598923e-03
## 60 -0.0245644263 4.122370e-02 0.0115498605 0.0138405134 -2.511708e-02
## 61 0.0456183643 3.753803e-02 -0.0024279337 -0.0704644860 -3.148941e-02
## 62 -0.0011287003 4.658709e-03 0.0138382169 0.0237236991 1.518008e-02
## 64 0.0195871677 -1.445688e-02 -0.0439719903 0.0126420322 6.497044e-03
## 65 -0.0027777314 2.727356e-02 0.0120405964 -0.0114251795 -9.501791e-03
## 66 -0.0024440009 -2.419782e-02 0.0351816461 0.0217028921 -4.594993e-03
## 67 0.0044369486 -4.183243e-02 0.0136750619 -0.0271911881 -2.478377e-02
## 68 -0.0313449691 7.468458e-04 0.0128265054 -0.0217931499 1.092577e-02
## 69 -0.0510515106 2.475796e-02 -0.0356524029 -0.0697494403 1.497216e-02
## 70 -0.0069784138 -7.011686e-03 -0.0095231602 -0.0115014259 1.596877e-02
## 71 0.0614499458 5.124099e-02 -0.0176483611 0.0630233833 -6.949425e-02
## 72 0.0754751022 -4.462584e-02 0.1133203679 0.0678594293 -8.178078e-03
## 73 -0.1274112296 -1.504672e-01 0.0056837590 0.0746388912 -3.816208e-02
## 74 0.0170825800 -2.962537e-03 0.0140109866 0.0077629784 -9.826425e-03
## Axis.56 Axis.57 Axis.58 Axis.59 Axis.60
## 1 -0.0047923390 -0.0227632418 0.0729244903 -0.0253680021 -0.0358734637
## 2 0.0165826991 -0.0221900104 0.0137625429 0.0054223291 -0.0090868881
## 3 0.0302143585 -0.0176528068 0.0097555726 -0.0088927641 0.0006793122
## 4 0.0243917321 -0.0382966405 0.0078659305 0.0017612534 0.0247635832
## 5 0.0153456999 0.0007363561 0.0021227616 0.0071716883 -0.0080771210
## 6 -0.0113093704 -0.0198435298 -0.0073286311 0.0107454756 0.0097408889
## 7 0.0065655178 0.0185139163 0.0043411752 0.0003732724 -0.0223248988
## 8 0.0209044023 -0.0201287100 0.0068291886 0.0201356579 -0.0203214567
## 9 0.0038713106 0.0115338390 -0.0083753718 0.0004166162 -0.0072985246
## 10 0.0141893101 -0.0067388884 0.0097442184 -0.0135372907 0.0015373461
## 11 0.0398551743 0.0145136817 0.0741903179 -0.0172601325 0.0391496377
## 12 0.0212398729 -0.0001270852 0.0126946426 -0.0025800776 0.0091471012
## 13 0.1821340528 0.0976748874 0.0575907412 -0.0353236923 -0.0395555422
## 14 -0.0171323052 0.0190778833 -0.0166334999 0.0008356493 0.0108126908
## 15 -0.0023604537 0.0087158819 -0.0014965324 -0.0120603553 -0.0102618936
## 16 -0.0424560822 0.1310211664 0.0178980250 -0.0418005162 0.0633801326
## 17 -0.0419702913 0.0030452796 -0.0430980815 0.0173426122 -0.0069608991
## 18 -0.0053874376 -0.0007473519 0.0329822765 -0.0358138996 -0.0333797384
## 19 -0.0024830043 0.0179442764 -0.0025407770 0.0019143732 0.0006103795
## 20 0.0014284974 -0.0066049034 0.0052234372 -0.0005963472 -0.0016377078
## 21 -0.0286642515 -0.1239047736 -0.0137588798 0.0922626015 -0.0372614449
## 22 0.0275020922 0.0056197604 0.0103347711 -0.0514740608 0.0941446327
## 23 -0.0285576717 0.0020402583 -0.0189044859 0.0057400096 -0.0013229063
## 24 0.0665866553 -0.0239516674 -0.0296580326 0.0317365362 -0.0022390984
## 25 -0.0884660777 -0.0067045944 0.0556074700 -0.0915679537 -0.0449312033
## 26 -0.0002481242 0.0089539984 -0.0027288996 -0.0021819503 0.0074879203
## 27 -0.0288331163 0.0008341789 -0.0740035726 0.0143620898 0.0101743618
## 28 -0.0084109473 0.1365270344 -0.0655631425 0.0829041012 -0.1394027458
## 29 0.0187003568 -0.0201453841 -0.0581068470 -0.0081421323 0.0016400757
## 30 -0.0006101555 -0.0259776580 0.0065671659 -0.0038075282 -0.0089211052
## 31 -0.0434415146 -0.0002913718 0.0145875382 -0.0363105789 -0.0073312557
## 32 0.0492094030 -0.0794959628 0.0491690445 -0.0126423744 -0.0373229281
## 33 -0.0131790302 0.0225172582 -0.0036064091 -0.0065214275 -0.0267088108
## 34 0.0189634480 0.0088101890 0.0144457205 0.0077563554 -0.0122278426
## 35 0.0085416221 -0.0014606771 0.0125272486 -0.0142086047 0.0069967822
## 36 -0.0076549925 0.0059892281 -0.0075044521 0.0115693038 0.0077693457
## 37 -0.0016923780 0.0203513362 -0.0061391187 0.0493204680 0.0261893842
## 38 0.0089080831 0.0099811043 -0.0371926746 0.0375168132 0.0919237449
## 39 0.0114931780 0.0034407197 -0.0096085021 0.0010046098 0.0211961346
## 40 0.0106179485 0.0024725228 -0.0146355684 0.0185687722 -0.0124675221
## 41 -0.0691743667 0.0222284364 0.0149861174 0.0471945790 0.0428897213
## 42 0.0049086582 -0.1229510026 -0.0164896574 -0.0298702616 -0.0088628465
## 43 -0.0741698149 0.0109669903 -0.0167784130 -0.0254501642 0.0001317646
## 44 -0.0423341537 0.0054319106 0.0098427384 0.0098556727 -0.0771469761
## 45 0.0278572985 -0.0343502733 0.0101460183 -0.0132264695 -0.0008619825
## 46 -0.1040564767 0.0313329335 -0.0284174474 -0.0191039403 0.0258010876
## 47 0.1082239529 0.0076039352 -0.1010015818 -0.0807384575 -0.0106501227
## 49 0.0165287005 0.0022127460 -0.0232016358 0.0113495225 0.0123713091
## 50 -0.0136526148 -0.0378085463 0.0689249581 0.0518842548 -0.0030271274
## 51 0.0371302549 -0.0262325747 0.0017608440 0.0213806962 0.0105101213
## 52 -0.0082583249 0.0380004250 -0.0026736003 -0.0054352182 -0.0007548958
## 53 -0.0501219847 0.0398906584 0.0798334671 0.0216129576 0.0006982550
## 54 -0.0243733727 -0.0006785268 -0.0163173444 0.0202138924 0.0091735944
## 56 -0.0068140459 0.0027277921 -0.0052920418 0.0040811678 0.0064978017
## 57 -0.0228001820 -0.0290845978 -0.0854335118 -0.0495694954 -0.0066234111
## 58 -0.0090417721 -0.0006781859 -0.0028111070 -0.0062346578 -0.0057444917
## 59 -0.0007341286 0.0128978788 0.0037898686 -0.0118462246 0.0086704013
## 60 0.0622473540 0.0236911052 0.0600259836 0.1240938630 0.0535757184
## 61 0.0198245175 -0.0262347401 0.0017224758 -0.0538690412 -0.0348502290
## 62 -0.0059283380 0.0035954875 -0.0170394517 -0.0321963025 0.0257113751
## 64 0.0051047330 -0.0133085318 0.0087421760 -0.0071901998 -0.0047320569
## 65 -0.0092313640 0.0092303817 0.0070888159 -0.0110505046 -0.0052646066
## 66 -0.0165733407 -0.0054078755 0.0093870480 -0.0119662756 -0.0047041623
## 67 -0.0481314512 -0.0111440451 0.0646001832 0.0177108556 -0.0129737193
## 68 -0.0304525751 -0.0003972136 0.0007937636 -0.0030262602 0.0220390599
## 69 0.0150220375 -0.0005473823 0.0004763906 -0.0024495101 -0.0058962741
## 70 0.0027835645 0.0071151528 0.0010081039 0.0026777932 0.0070826274
## 71 0.0491071696 -0.0111892196 -0.0678180411 0.0428817438 0.0256739296
## 72 -0.0180365610 -0.0070416342 -0.0084286336 -0.0194190491 0.0359599405
## 73 -0.0115978378 -0.0066976367 -0.0123530625 0.0054960605 -0.0052691723
## 74 -0.0028514072 0.0035366530 -0.0093542234 0.0034380733 -0.0018530906
## Axis.61 Axis.62 Axis.63 Axis.64 Axis.65
## 1 -0.0094352634 0.0156943135 1.001939e-02 -0.018465755 2.583975e-02
## 2 0.0142896057 -0.0030849724 -1.282847e-03 0.005748186 6.854686e-03
## 3 0.0078355445 -0.0034548417 4.114496e-03 0.001515304 -3.876597e-03
## 4 0.0030350413 -0.0014454386 2.316001e-03 -0.002587012 -4.234322e-03
## 5 -0.0119946907 0.0025272311 -3.201356e-03 0.009160360 1.501764e-03
## 6 0.0028448187 -0.0021046602 -9.535272e-04 0.003026635 2.863500e-03
## 7 -0.0242561862 -0.0003141205 -1.005891e-02 0.013813185 -4.386013e-04
## 8 -0.0002459635 0.0079293615 -5.316827e-03 0.002919315 1.628289e-02
## 9 0.0014958635 -0.0015234990 -5.702596e-04 -0.000884577 3.884611e-03
## 10 0.0107045878 -0.0065788202 9.302388e-04 0.005037926 -9.210196e-04
## 11 0.1576725719 -0.0301060435 -1.382020e-02 0.063935859 -2.200284e-03
## 12 -0.0028292788 0.0043107911 -3.173995e-03 0.003057771 -1.226955e-03
## 13 -0.0306898129 0.0213094295 -1.659257e-02 0.005102993 -2.409873e-02
## 14 -0.0255424099 0.0112128997 1.790927e-03 -0.005126536 -2.124555e-03
## 15 0.0065918262 -0.0009948366 3.649402e-03 -0.012901793 1.743714e-03
## 16 0.0222234430 -0.0059686849 9.574937e-03 -0.001507224 -3.724195e-02
## 17 -0.0305879755 -0.0021277968 1.942418e-03 -0.005604661 1.838307e-03
## 18 -0.0317696233 -0.0169691130 1.157082e-01 0.058398607 -7.194384e-03
## 19 0.0025055227 -0.0013053673 2.304820e-04 0.001273225 -7.616792e-04
## 20 -0.0005585845 0.0012437498 2.365745e-03 -0.003788212 -3.302276e-03
## 21 0.0180800954 0.0487108063 -3.536110e-02 0.014965904 -1.617259e-03
## 22 -0.0377701515 0.0124241226 2.018582e-02 -0.097748703 -1.270813e-02
## 23 -0.0199016947 -0.0055242786 4.433455e-03 -0.009421964 -9.946737e-04
## 24 0.0120166436 -0.0126630320 -6.197700e-03 -0.002004966 6.230510e-03
## 25 -0.0590672465 0.0106308701 -9.468762e-04 0.026206324 8.817401e-03
## 26 -0.0065026072 0.0015806037 -2.845282e-03 0.004698352 -1.661382e-03
## 27 -0.0001421276 -0.1039208458 3.683984e-02 0.012357169 1.877724e-02
## 28 -0.0033012941 -0.0062561894 8.911332e-03 -0.012744909 -1.131664e-02
## 29 0.0222903430 0.0420204031 -1.638856e-02 0.016010970 1.222125e-03
## 30 -0.0154263404 0.0087374801 -2.904882e-04 -0.002901797 2.002466e-04
## 31 -0.0169535002 -0.0645316122 -1.181539e-01 -0.029665307 -2.091947e-02
## 32 -0.0023500918 0.0103370809 7.753153e-03 -0.022427215 1.994510e-03
## 33 0.0187794320 -0.0097291078 3.183344e-03 -0.012726840 -3.273258e-03
## 34 -0.0027861065 0.0095193793 -4.424972e-04 0.012948179 6.134316e-04
## 35 0.0081973579 -0.0032644713 -1.276308e-03 0.005314347 3.341540e-03
## 36 0.0025100873 0.0058387720 -6.035265e-04 -0.001613883 -3.357795e-03
## 37 -0.0141875372 0.0129045673 -7.026840e-03 0.007748346 -1.180063e-02
## 38 -0.1180854666 0.0107098096 -3.133515e-02 0.090778427 -1.608446e-02
## 39 -0.0121301123 0.0024966851 4.932441e-03 -0.004713872 -7.096668e-04
## 40 -0.0187672266 0.0002118589 -3.110043e-03 0.007500302 4.131981e-03
## 41 0.0314654154 0.0931771179 5.190055e-02 -0.001997629 8.996116e-03
## 42 -0.0242879740 -0.0069271836 5.119238e-02 -0.022719088 -5.388293e-02
## 43 0.0411033534 0.0981506869 -2.147116e-02 -0.004766704 -4.339054e-02
## 44 -0.0043510078 0.0117661841 3.879149e-03 -0.022551292 7.526206e-03
## 45 -0.0122626901 0.0015664069 -1.206928e-03 0.004272289 6.948850e-03
## 46 0.0193100538 0.0095095655 -7.192250e-03 -0.016324493 2.751153e-02
## 47 0.0055862334 0.0743204882 -1.852948e-02 -0.002167515 4.917225e-02
## 49 0.0258408315 0.0026351178 5.295862e-03 0.012548358 -1.188010e-02
## 50 -0.0130663916 0.0073973226 -3.460202e-02 0.026681696 -5.202624e-03
## 51 0.0130966289 -0.0027380072 1.057362e-03 -0.007814849 -1.766833e-02
## 52 -0.0115873500 0.0033429391 -4.231742e-03 0.004203420 -2.383585e-03
## 53 -0.0026769434 -0.0061142223 -3.302559e-03 -0.002234478 5.064865e-03
## 54 0.0029448647 -0.0112366550 -9.203683e-03 -0.005612999 5.192289e-03
## 56 0.0008633456 -0.0026777049 -7.942597e-05 0.003872918 4.819365e-03
## 57 0.0475999807 -0.0489775193 3.330806e-03 0.011362980 -1.138992e-03
## 58 -0.0037720079 -0.0016171742 -4.262648e-03 0.004789485 -5.149065e-05
## 59 0.0170544791 -0.0067359547 1.192957e-03 0.005830395 1.769063e-03
## 60 -0.0153099973 -0.0232039799 1.980855e-02 -0.044190049 4.313098e-02
## 61 -0.0194148746 -0.0427114104 -9.149028e-03 0.008054682 -1.019265e-02
## 62 -0.0053550576 -0.0186074341 -6.638815e-03 0.004160239 9.768958e-02
## 64 0.0239120277 -0.0060358605 5.223517e-03 -0.005958433 2.561214e-03
## 65 0.0014957978 0.0052207693 -2.859793e-03 -0.003007172 4.584680e-03
## 66 0.0253231994 -0.0009066544 3.419309e-03 -0.014519546 -2.793936e-03
## 67 -0.0128199233 -0.0439286665 -1.142877e-02 -0.015230413 -1.660070e-03
## 68 -0.0014228273 -0.0039833604 3.549053e-03 0.002517927 1.781300e-03
## 69 0.0136282192 -0.0030118643 6.660336e-03 -0.008951558 -6.757294e-03
## 70 0.0001324229 0.0002792210 5.614213e-04 0.003962213 7.841165e-04
## 71 0.0233150512 -0.0405555728 1.271170e-02 -0.021129879 -4.966239e-02
## 72 -0.0245483147 0.0022287661 -1.246365e-03 -0.001045304 5.563440e-04
## 73 0.0480711637 -0.0020711195 5.716404e-03 -0.012171455 4.001521e-03
## 74 -0.0056592012 0.0039632750 -2.756998e-05 -0.004546206 5.011486e-04
## Axis.66 Axis.67 Axis.68
## 1 8.341235e-03 -2.505074e-03 -1.462734e-02
## 2 -3.312044e-03 2.906332e-03 2.836715e-03
## 3 -2.378382e-03 -9.993119e-04 3.888238e-03
## 4 5.880929e-04 -1.494977e-03 -1.681093e-03
## 5 -1.183567e-03 2.830698e-03 5.348683e-04
## 6 1.036359e-03 1.893281e-03 -5.180125e-04
## 7 -2.277815e-03 3.916711e-03 -2.376443e-03
## 8 -3.694068e-03 3.918093e-03 7.164715e-03
## 9 9.141698e-04 6.429807e-04 1.930168e-03
## 10 -1.684431e-03 1.569340e-03 8.513587e-04
## 11 -2.078114e-02 6.096423e-03 -1.055091e-02
## 12 1.880137e-03 -3.361135e-03 -1.180503e-03
## 13 7.585825e-05 -1.687757e-02 1.270350e-02
## 14 -1.241985e-03 -1.952217e-03 4.281291e-04
## 15 1.898794e-03 3.808503e-03 4.257112e-03
## 16 2.349906e-02 -4.426771e-03 -1.891725e-02
## 17 2.754089e-03 1.628774e-03 3.717064e-03
## 18 8.146321e-03 -1.855444e-02 1.380149e-02
## 19 1.031237e-03 -1.090172e-04 -1.728701e-04
## 20 2.688937e-04 3.473123e-04 1.099069e-03
## 21 1.449006e-02 -6.131493e-02 -9.328818e-03
## 22 4.400453e-02 -1.805357e-02 9.674392e-03
## 23 6.337698e-03 3.121356e-03 7.354733e-06
## 24 3.536290e-02 1.133488e-02 -1.542003e-03
## 25 -1.289122e-02 -2.391509e-02 -2.119019e-02
## 26 4.724209e-04 -1.966986e-03 -3.857049e-04
## 27 2.464735e-02 -1.297350e-02 -4.798091e-03
## 28 -1.658341e-03 1.470778e-02 -8.160230e-03
## 29 7.132198e-02 2.584154e-02 -1.858877e-02
## 30 -3.801583e-03 -3.378359e-04 -2.336521e-03
## 31 -2.876262e-02 -2.617181e-03 -4.706088e-03
## 32 -1.243144e-03 -6.759667e-03 2.286965e-03
## 33 3.477731e-03 5.064298e-04 2.533465e-03
## 34 -3.918565e-03 -1.744217e-03 1.752362e-03
## 35 1.953227e-03 -7.456349e-04 -2.070581e-03
## 36 -2.399730e-03 -2.090295e-03 -2.839410e-03
## 37 -3.840241e-03 5.652161e-03 3.768722e-03
## 38 -1.947130e-02 3.858642e-03 -5.126797e-03
## 39 1.463184e-03 2.465918e-03 1.095210e-03
## 40 -1.933420e-03 1.456253e-03 2.724744e-03
## 41 -2.071189e-02 -3.679493e-03 2.337108e-03
## 42 -4.558549e-02 5.786775e-02 -2.113308e-02
## 43 -1.716626e-02 9.893639e-03 3.307201e-02
## 44 -8.265863e-03 2.678235e-03 9.000430e-03
## 45 -7.317432e-03 -9.982748e-04 8.406818e-04
## 46 -1.938598e-02 -9.190595e-03 -1.515537e-02
## 47 -2.205226e-02 -4.092254e-04 -2.442627e-02
## 49 2.545956e-03 4.165719e-03 -4.976453e-03
## 50 5.327769e-02 2.982687e-02 2.382623e-02
## 51 4.188651e-03 -3.920023e-03 -3.709335e-03
## 52 -1.172067e-03 -6.921658e-04 9.754122e-04
## 53 -2.545060e-03 3.484443e-03 2.210153e-04
## 54 8.894202e-03 6.928466e-03 -4.568074e-03
## 56 1.415195e-04 2.324627e-03 7.111490e-04
## 57 7.460854e-03 -1.099985e-02 -4.707214e-03
## 58 -2.073401e-03 -3.440709e-04 1.262437e-03
## 59 3.018027e-03 -3.010272e-03 -2.188562e-03
## 60 -3.513587e-02 1.075351e-03 -3.382303e-02
## 61 -3.840942e-04 -5.584373e-03 5.561107e-04
## 62 -1.800069e-02 1.961656e-02 5.377174e-02
## 64 1.511263e-03 -1.435293e-03 -1.091857e-03
## 65 -3.213664e-03 2.681491e-03 3.343543e-04
## 66 4.824654e-03 -1.149151e-03 -7.572237e-04
## 67 1.123267e-02 1.148053e-02 6.001104e-03
## 68 3.447684e-03 3.178384e-04 -4.597131e-03
## 69 -5.469269e-04 2.480959e-03 -1.924352e-03
## 70 2.151296e-04 8.685758e-05 1.517317e-03
## 71 -4.141265e-02 -2.884330e-02 3.772238e-02
## 72 7.072984e-03 -1.858269e-03 -8.474351e-04
## 73 2.281735e-03 -4.950614e-04 3.310159e-03
## 74 -2.635163e-03 1.996092e-03 2.487728e-03
##
## $trace
## [1] 30.50281
# Create a modified version of the data with the updated species labels
pcoa.table_phenology_modified <- pcoa.table_phenology
pcoa.table_phenology_modified$Species <- str_replace_all(pcoa.table_phenology_modified$Species,
"_", " ")
################################################################################ (a)
################################################################################ Bray-Curtis
################################################################################ b/w
################################################################################ Host
################################################################################ Species
################################################################################ (Size
################################################################################ =
################################################################################ Diversity)
library(stringr)
Phenology_beta_leaf <- ggplot(pcoa.table_phenology_modified, aes(x = Axis.1, y = Axis.2)) +
geom_point(aes(color = Species, size = alphaDiv), alpha = 0.85) + labs(title = paste0("Bray-Curtis Distance, size represents diversity"),
x = "Axis 1 [12.61%]", y = "Axis 2 [10.38%]") + guides(color = guide_legend(override.aes = list(alpha = 1))) +
theme(legend.position = "bottom", plot.title = element_text(size = 14)) + scale_custom_two
Phenology_beta_leaf + theme_cowplot(12)
# Save the plot as a JPEG image
ggsave(filename = "Phenology_beta_shannon_species.jpeg", plot = Phenology_beta_leaf,
device = "jpeg", width = 12, height = 6, units = "in")
# Exclude the value 323 from Growing-Degree-Days-5C
pcoa.table_phenology_filtered <- pcoa.table_phenology_modified %>%
filter(GDD_5C != 323)
################################################################################ (b)
################################################################################ Bray-Curtis
################################################################################ b/w
################################################################################ Host
################################################################################ Species
################################################################################ (further
################################################################################ differentiated
################################################################################ by
################################################################################ GDDs;
################################################################################ Size
################################################################################ =
################################################################################ Diversity)
library(ggplot2)
library(dplyr)
# Define the sampling points for GDD
sampling_points <- c(437, 605, 1087, 1606, 1992, 2140, 2219)
# Create a new categorical variable based on sampling points
pcoa.table_phenology_filtered$GDD_5C_bins <- cut(pcoa.table_phenology_filtered$GDD_5C,
breaks = c(-Inf, sampling_points, Inf), labels = c("437", "605", "1087", "1606",
"1992", "2140", "2219", "2220+"), include.lowest = TRUE)
# Define the custom shapes for each level of Growing-Degree-Days-5C
shapes <- c(21, 22, 23, 18, 8, 15, 17, 19)
Phenology_beta_gdd <- ggplot(pcoa.table_phenology_filtered, aes(x = Axis.1, y = Axis.2)) +
geom_point(aes(color = Species, size = alphaDiv, shape = GDD_5C_bins), alpha = 0.85) +
labs(title = paste0("Bray-Curtis Distance (by Growing Degree Days (5C); size = Shannon Diversity)"),
x = "Axis 1 [12.61%]", y = "Axis 2 [10.38%]") + guides(color = guide_legend(override.aes = list(alpha = 1))) +
theme(legend.position = "bottom", plot.title = element_text(size = 20)) + scale_shape_manual(values = shapes) +
labs(shape = "Growing Degree Days (5C)") + scale_custom_two
Phenology_beta_gdd + theme_cowplot(12)
# Save the plot as a JPEG image
ggsave(filename = "Phenology_beta_shannon_gdd.jpeg", plot = Phenology_beta_gdd, device = "jpeg",
width = 12, height = 6, units = "in")
write.csv(pcoa.table_phenology_filtered, "pcoa.table_phenology_filtered.csv")
################################################################################
##(d) Bray-Curtis b/w Host Species (further differentiated by GDDs; Size = ASV Richness)
################################################################################
library(ggplot2)
# Define the sampling points for GDD
sampling_points <- c(437, 605, 1087, 1606, 1992, 2140, 2219)
# Create a new categorical variable based on sampling points
pcoa.table_phenology_filtered$GDD_5C_bins <- cut(pcoa.table_phenology_filtered$GDD_5C,
breaks = c(-Inf, sampling_points, Inf),
labels = c("437", "605", "1087", "1606", "1992", "2140", "2219", "2220+"),
include.lowest = TRUE
)
# Define the custom shapes for each unique GDD value
shapes <- c(21, 22, 23, 18, 8, 15, 17, 19)
Phenology_beta_asvgdd <- ggplot(pcoa.table_phenology_filtered, aes(x = Axis.1, y = Axis.2)) +
geom_point(aes(shape = GDD_5C_bins, color = Species, size = specnumber)) +
labs(title = paste0("Bray-Curtis Distance (by Growing Degree Days (5C); size = ASV Richness)"),
color = "Species", shape = "Growing Degree Days 5C",
x = "Axis 1 [12.61%]",
y = "Axis 2 [10.38%]") +
guides(color = guide_legend(override.aes = list(alpha = 1))) +
scale_shape_manual(values = shapes) +
labs(shape = "Growing Degree Days 5C") + # Update shape legend label
scale_custom_two
Phenology_beta_asvgdd + theme_cowplot(12)
# Save the plot as a JPEG image
ggsave(filename = "Phenology_beta_asvrich_gdd.jpeg", plot = Phenology_beta_asvgdd,
device = "jpeg", width = 12, height = 6, units = "in")
################################################################################
##(e) Bray-Curtis b/w Host Species (further differentiated by GDDs; NO SIZE
################################################################################
library(ggplot2)
library(grid)
# Define the sampling points for GDD
sampling_points <- c(437, 605, 1087, 1606, 1992, 2140, 2219)
# Create a new categorical variable based on sampling points
pcoa.table_phenology_filtered$GDD_5C_bins <- cut(pcoa.table_phenology_filtered$GDD_5C,
breaks = c(-Inf, sampling_points, Inf),
labels = c("437", "605", "1087", "1606", "1992", "2140", "2219", "2220+"),
include.lowest = TRUE
)
# Define the custom shapes for each unique GDD value
shapes <- c(21, 22, 23, 18, 8, 15, 17, 19)
Phenology_beta_nosize <- ggplot(pcoa.table_phenology_filtered, aes(x = Axis.1, y = Axis.2)) +
geom_point(aes(shape = GDD_5C_bins, color = Species), size = 3) +
labs(color = "Species", shape = "Growing Degree Days (5\u00B0C)",
x = "Axis 1 [12.61%]",
y = "Axis 2 [10.38%]") +
guides(color = guide_legend(override.aes = list(alpha = 1))) +
scale_shape_manual(values = shapes) +
labs(shape = "Growing Degree Days (5\u00B0C)") + # Update shape legend label
scale_custom_two +
theme(
axis.title.x = element_text(size = 9),
axis.title.y = element_text(size = 9),
axis.text.x = element_text(size = 7),
axis.text.y = element_text(size = 7),
legend.title = element_text(size = 7),
legend.text = element_text(size = 7),
panel.border = element_rect(color = "black", size = 1, fill = NA),
axis.ticks = element_line(color = "black"),
plot.margin = unit(c(1, 1, 1, 1), "pt")
)
Phenology_beta_nosize
# Save the plot as a JPEG image
ggsave(filename = "Phenology_beta_nosize.jpeg", plot = Phenology_beta_nosize, device = "jpeg",
width = 7, height = 5, units = "in")
Phenology_beta_nosize2 <- ggplot(
pcoa.table_phenology_filtered %>%
dplyr::mutate(Species = forcats::fct_recode(
Species,
"B. populifolia" = "Betula populifolia",
"P. tremuloides" = "Populus tremuloides"
)),
aes(x = Axis.1, y = Axis.2)
) +
geom_point(aes(shape = GDD_5C_bins, color = Species), size = 3) +
labs(
color = "Species",
shape = "Growing Degree Days (5\u00B0C)",
x = "Axis 1 [12.61%]",
y = "Axis 2 [10.38%]"
) +
scale_shape_manual(values = shapes) +
scale_custom_two +
guides(
color = guide_legend(
title = "Species",
nrow = 2,
keyheight = unit(0.2, "cm"),
keywidth = unit(0.2, "cm"),
override.aes = list(size = 1)
),
shape = guide_legend(
title = "GDD (5\u00B0C)",
keyheight = unit(0.2, "cm"),
keywidth = unit(0.2, "cm"),
override.aes = list(size = 1)
)
) +
theme(
axis.title.x = element_text(size = 7),
axis.title.y = element_text(size = 7),
axis.text.x = element_text(size = 6),
axis.text.y = element_text(size = 6),
legend.title = element_text(size = 5),
legend.text = element_text(size = 5),
panel.border = element_rect(color = "black", size = 1, fill = NA),
axis.ticks = element_line(color = "black"),
plot.margin = unit(c(0.6, 0.6, 0.5, 5), "pt"),
legend.position = "bottom",
legend.box = "horizontal",
legend.box.just = "center",
# ↓ These lines reduce spacing between legend boxes
legend.spacing.x = unit(0.02, "pt"),
legend.spacing.y = unit(0.02, "pt")
)
Phenology_beta_nosize2
library(stringr)
library(ggplot2)
library(grid)
library(dplyr)
# Define the sampling points for GDD
sampling_points <- c(437, 605, 1087, 1606, 1992, 2140, 2219)
# Create a new categorical variable based on sampling points
pcoa.table_phenology_filtered$GDD_5C_bins <- cut(pcoa.table_phenology_filtered$GDD_5C,
breaks = c(-Inf, sampling_points, Inf),
labels = c("437", "605", "1087", "1606", "1992", "2140", "2219", "2220+"),
include.lowest = TRUE
)
# Define the custom shapes for each unique GDD value
shapes <- c(21, 22, 23, 18, 15, 19, 8, 17)
# Make PCoA
Phenology_beta_nosize3 <- ggplot(
pcoa.table_phenology_filtered %>%
dplyr::mutate(Species = forcats::fct_recode(
Species,
"Grey Birch" = "Betula populifolia",
"Trembling Aspen" = "Populus tremuloides"
)),
aes(x = Axis.1, y = Axis.2)
) +
geom_point(aes(color = Species, shape = GDD_5C_bins), size = 2) +
labs(
color = "Species",
shape = expression("GDD (" * T[base] * " = 5"~degree*C * ")"),
x = "Axis 1 [12.61%]",
y = "Axis 2 [10.38%]"
) +
scale_shape_manual(values = shapes) +
scale_custom_two +
guides(
color = guide_legend(
title = "Host Species",
ncol = 1,
keyheight = unit(0.3, "cm"),
keywidth = unit(0.3, "cm"),
override.aes = list(size = 2)
),
shape = guide_legend(
title = expression("GDD (" * T[base] * " = 5"~degree*C * ")"),
ncol = 1,
keyheight = unit(0.3, "cm"),
keywidth = unit(0.3, "cm"),
override.aes = list(size = 2)
)
) +
theme(
axis.title.x = element_text(size = 9),
axis.title.y = element_text(size = 9),
axis.text.x = element_text(size = 8),
axis.text.y = element_text(size = 8),
legend.title = element_text(size = 8),
legend.text = element_text(size = 8),
panel.border = element_rect(color = "black", fill = NA, size = 1),
panel.grid = element_blank(),
panel.background = element_rect(fill = "white", color = NA),
axis.ticks = element_line(color = "black"),
plot.margin = unit(c(5, 1, 1, 1), "pt")
# legend.position = "right",
# legend.box = "vertical", # stack color & shape legends vertically
# legend.box.just = "center",
# legend.spacing = unit(0, "mm") # small space between the two legend rows
)
Phenology_beta_nosize3
# Save the plot as a JPEG image
ggsave(filename = "Phenology_beta_nosize3.png", plot = Phenology_beta_nosize3, device = "png",
width = 7, height = 5, units = "in")
# Define the custom shapes for each unique GDD value
shapes <- c(21, 22, 23, 18, 8, 15, 17, 19)
Phenology_beta_axis3 <- ggplot(pcoa.table_phenology_filtered, aes(x = Axis.1, y = Axis.3)) +
geom_point(aes(shape = GDD_5C_bins, color = Species), size = 5) +
labs(title = paste0("Bray-Curtis Distance (by Growing Degree Days (5C)"),
color = "Species", shape = "Growing Degree Days 5C",
x = "Axis 1 [12.61%]",
y = "Axis 3 [? %]") +
guides(color = guide_legend(override.aes = list(alpha = 1))) +
scale_shape_manual(values = shapes) +
labs(shape = "Growing Degree Days 5C") + # Update shape legend label
scale_custom_two
Phenology_beta_axis3 + theme_cowplot(12)
################################################################################ Calculate
################################################################################ the
################################################################################ percentage
################################################################################ variance
################################################################################ explained
################################################################################ by
################################################################################ each
################################################################################ axis
# Perform CAP analysis
cap_result <- capscale(dist.mat ~ 1, data = pcoa.table_phenology)
# Extract percentage variance explained by each axis
percent_var_explained <- round(cap_result$CA$eig/sum(cap_result$CA$eig) * 100, 2)
# Print the results
print(percent_var_explained)
## MDS1 MDS2 MDS3 MDS4 MDS5 MDS6 MDS7 MDS8 MDS9 MDS10 MDS11 MDS12 MDS13
## 12.60 10.37 4.44 3.49 3.31 3.07 2.59 2.41 2.21 2.13 2.04 2.00 1.90
## MDS14 MDS15 MDS16 MDS17 MDS18 MDS19 MDS20 MDS21 MDS22 MDS23 MDS24 MDS25 MDS26
## 1.89 1.79 1.75 1.69 1.63 1.62 1.57 1.52 1.43 1.42 1.39 1.36 1.34
## MDS27 MDS28 MDS29 MDS30 MDS31 MDS32 MDS33 MDS34 MDS35 MDS36 MDS37 MDS38 MDS39
## 1.27 1.26 1.23 1.18 1.13 1.13 1.09 1.05 1.04 1.01 0.95 0.92 0.89
## MDS40 MDS41 MDS42 MDS43 MDS44 MDS45 MDS46 MDS47 MDS48 MDS49 MDS50 MDS51 MDS52
## 0.86 0.84 0.82 0.79 0.76 0.72 0.72 0.65 0.63 0.60 0.58 0.54 0.53
## MDS53 MDS54 MDS55 MDS56 MDS57 MDS58 MDS59 MDS60 MDS61 MDS62 MDS63 MDS64 MDS65
## 0.52 0.49 0.45 0.38 0.33 0.28 0.26 0.24 0.21 0.18 0.14 0.12 0.09
## MDS66 MDS67 MDS68
## 0.07 0.04 0.04
# OR, another likely more valid way for PCoA is this, but they yield the same
# result essentially:
# Extract eigenvalues for Axis 1 and Axis 2
eigenvalues_axis1_inter <- pcoa.asv$values$Eigenvalues[1]
eigenvalues_axis2_inter <- pcoa.asv$values$Eigenvalues[2]
# Calculate the total sum of eigenvalues for normalization
total_eigenvalues_inter <- sum(pcoa.asv$values$Eigenvalues)
# Calculate the percentage of variance explained by Axis 1 and Axis 2
variance_explained_axis1_inter <- eigenvalues_axis1_inter/total_eigenvalues_inter *
100
variance_explained_axis2_inter <- eigenvalues_axis2_inter/total_eigenvalues_inter *
100
# Print the results
print(variance_explained_axis1_inter)
## [1] 12.61088
print(variance_explained_axis2_inter)
## [1] 10.37888
################################################################################ COMBINING
################################################################################ PLOTS
################################################################################ AS
################################################################################ PANELS
################################################################################ INTO
################################################################################ RESPECTIVE
################################################################################ FIGURES
library(gridExtra)
# Total Alpha Diversity (for sequencing QC):
beta_gdd_combined <- arrangeGrob(Phenology_beta_asvgdd, Phenology_beta_gdd, nrow = 3)
ggsave("beta_gdd_combined.png", beta_gdd_combined, width = 16, height = 32)
fig1_div_combined_v1 <- arrangeGrob(Phenology_richness_gddspec2, Phenology_diversity_gddspec2,
Phenology_beta_nosize, ncol = 1, nrow = 2)
fig1_div_combined_v2 <- arrangeGrob(alpha_combined, Phenology_beta_nosize, relabund_phyla_combined,
relabund_genus_combined, ncol = 2, nrow = 2)
ggsave("fig1_div_combined.png", fig1_div_combined, width = 30, height = 16)
# Loop through each growing degree day and create a separate PCoA plot
for (gdd_value in unique(pcoa.table_phenology_filtered$GDD_5C)) {
subset_data_pcoa <- subset(pcoa.table_phenology_filtered, GDD_5C == gdd_value)
pcoa_plot_gdd <- ggplot(subset_data_pcoa, aes(x = Axis.1, y = Axis.2, color = Species,
size = 3)) + geom_point(alpha = 0.85) + labs(title = paste("Bray-Curtis Distance - Growing Degree Days:",
gdd_value), x = "Axis 1", y = "Axis 2") + theme(legend.position = "bottom",
plot.title = element_text(size = 14))
# Print each PCoA plot
print(pcoa_plot_gdd)
}
# Load the ggplot2 package if not already loaded
library(ggplot2)
# Set a directory to save the JPG files
beta_gdds <- "C:/Users/jwils/OneDrive/Documents/Grad_Studies/Microbial_Leaf_Spec_Project/microbe_data/MiSeq_data/MiSeq_16S/Phenology/FigsTables_Final"
dir.create(beta_gdds, showWarnings = FALSE)
# Loop through each growing degree day and create a separate PCoA plot
for (gdd_value in unique(pcoa.table_phenology_filtered$GDD_5C)) {
subset_data_pcoa <- subset(pcoa.table_phenology_filtered, GDD_5C == gdd_value)
pcoa_plot_gdd <- ggplot(subset_data_pcoa, aes(x = Axis.1, y = Axis.2, color = Species,
size = 3)) + geom_point(alpha = 0.85) + labs(title = paste("Bray-Curtis Distance - Growing Degree Days:",
gdd_value), x = "Axis 1", y = "Axis 2") + theme(legend.position = "bottom",
plot.title = element_text(size = 14))
# Define the filename based on the growing degree day value
filename <- paste0(beta_gdds, "/pcoa_plot_gdd_", gdd_value, ".jpg")
# Save each PCoA plot as a JPG file
ggsave(filename, pcoa_plot_gdd, width = 8, height = 6, dpi = 300)
}
library(gridExtra)
library(jpeg)
# Load your saved plots
plot437 <- rasterGrob(readJPEG("C:/Users/jwils/OneDrive/Documents/Grad_Studies/Microbial_Leaf_Spec_Project/microbe_data/MiSeq_data/MiSeq_16S/Phenology/FigsTables_Final/pcoa_plot_gdd_437.jpg"),
interpolate = TRUE)
plot605 <- rasterGrob(readJPEG("C:/Users/jwils/OneDrive/Documents/Grad_Studies/Microbial_Leaf_Spec_Project/microbe_data/MiSeq_data/MiSeq_16S/Phenology/FigsTables_Final/pcoa_plot_gdd_605.jpg"),
interpolate = TRUE)
plot1087 <- rasterGrob(readJPEG("C:/Users/jwils/OneDrive/Documents/Grad_Studies/Microbial_Leaf_Spec_Project/microbe_data/MiSeq_data/MiSeq_16S/Phenology/FigsTables_Final/pcoa_plot_gdd_1087.jpg"),
interpolate = TRUE)
plot1606 <- rasterGrob(readJPEG("C:/Users/jwils/OneDrive/Documents/Grad_Studies/Microbial_Leaf_Spec_Project/microbe_data/MiSeq_data/MiSeq_16S/Phenology/FigsTables_Final/pcoa_plot_gdd_1606.jpg"),
interpolate = TRUE)
plot1992 <- rasterGrob(readJPEG("C:/Users/jwils/OneDrive/Documents/Grad_Studies/Microbial_Leaf_Spec_Project/microbe_data/MiSeq_data/MiSeq_16S/Phenology/FigsTables_Final/pcoa_plot_gdd_1992.jpg"),
interpolate = TRUE)
plot2140 <- rasterGrob(readJPEG("C:/Users/jwils/OneDrive/Documents/Grad_Studies/Microbial_Leaf_Spec_Project/microbe_data/MiSeq_data/MiSeq_16S/Phenology/FigsTables_Final/pcoa_plot_gdd_2140.jpg"),
interpolate = TRUE)
plot2219 <- rasterGrob(readJPEG("C:/Users/jwils/OneDrive/Documents/Grad_Studies/Microbial_Leaf_Spec_Project/microbe_data/MiSeq_data/MiSeq_16S/Phenology/FigsTables_Final/pcoa_plot_gdd_2219.jpg"),
interpolate = TRUE)
# Arrange the plots in a grid
pcoas_gdd_combined <- arrangeGrob(plot437, plot605, plot1087, plot1606, plot1992,
plot2140, plot2219, ncol = 3, nrow = 3)
# Save the combined plot
ggsave("pcoas_gdd_combined.png", pcoas_gdd_combined, width = 12, height = 8) # Adjust width and height as needed
################################################################################ PERCENT
################################################################################ VARIANCE
################################################################################ EXPLAINED
################################################################################ BY
################################################################################ AXIS
################################################################################ 1
################################################################################ &
################################################################################ AXIS
################################################################################ 2
data_437 <- asv_scaled_noPlants_Phen_filt_LMM[asv_scaled_noPlants_Phen_filt_LMM$GDD_5C ==
437, ]
data_605 <- asv_scaled_noPlants_Phen_filt_LMM[asv_scaled_noPlants_Phen_filt_LMM$GDD_5C ==
605, ]
data_1087 <- asv_scaled_noPlants_Phen_filt_LMM[asv_scaled_noPlants_Phen_filt_LMM$GDD_5C ==
1087, ]
data_1606 <- asv_scaled_noPlants_Phen_filt_LMM[asv_scaled_noPlants_Phen_filt_LMM$GDD_5C ==
1606, ]
data_1992 <- asv_scaled_noPlants_Phen_filt_LMM[asv_scaled_noPlants_Phen_filt_LMM$GDD_5C ==
1992, ]
data_2140 <- asv_scaled_noPlants_Phen_filt_LMM[asv_scaled_noPlants_Phen_filt_LMM$GDD_5C ==
2140, ]
data_2219 <- asv_scaled_noPlants_Phen_filt_LMM[asv_scaled_noPlants_Phen_filt_LMM$GDD_5C ==
2219, ]
################################################################################ GDD_437
asv_437 <- data_437[rowSums(data_437[, grepl("ASV", colnames(data_437))]) != 0, ]
distance = "bray"
dist.mat_437 <- vegan::vegdist(asv_437[, grepl("ASV", colnames(asv_437))], method = distance)
pcoa_437 <- pcoa(dist.mat_437)
pcoa.table_437 <- cbind(pcoa_437$vectors[, 1:5], asv_437[, !grepl("ASV", colnames(asv_437))])
pcoa.table_437$Axis.1
## [1] 0.02000567 0.26330396 0.22889845 0.17736267 -0.42299047 -0.45822232
## [7] -0.21264480 0.08218516 0.35608998 -0.03398830
# Perform CAP analysis for GDD_5C value 437
cap_result_437 <- capscale(dist.mat_437 ~ 1, data = pcoa.table_437)
# Extract percentage variance explained by each axis
percent_var_explained_437 <- round(cap_result_437$CA$eig/sum(cap_result_437$CA$eig) *
100, 2)
# Print the results for GDD_5C value 437
print(percent_var_explained_437)
## MDS1 MDS2 MDS3 MDS4 MDS5 MDS6 MDS7 MDS8 MDS9
## 18.50 15.78 12.71 11.63 10.84 9.43 9.32 8.56 3.25
#### OR:
# Extract eigenvalues for Axis 1 and Axis 2
eigenvalues_axis1_437 <- pcoa_437$values$Eigenvalues[1]
eigenvalues_axis2_437 <- pcoa_437$values$Eigenvalues[2]
# Calculate the total sum of eigenvalues for normalization
total_eigenvalues_437 <- sum(pcoa_437$values$Eigenvalues)
# Calculate the percentage of variance explained by Axis 1 and Axis 2
variance_explained_axis1_437 <- eigenvalues_axis1_437/total_eigenvalues_437 * 100
variance_explained_axis2_437 <- eigenvalues_axis2_437/total_eigenvalues_437 * 100
# Print the results
print(variance_explained_axis1_437)
## [1] 18.49698
print(variance_explained_axis2_437)
## [1] 15.77621
################################################################################ GDD_605
asv_605 <- data_605[rowSums(data_605[, grepl("ASV", colnames(data_605))]) != 0, ]
distance = "bray"
dist.mat_605 <- vegan::vegdist(asv_605[, grepl("ASV", colnames(asv_605))], method = distance)
pcoa_605 <- pcoa(dist.mat_605)
pcoa.table_605 <- cbind(pcoa_605$vectors[, 1:5], asv_605[, !grepl("ASV", colnames(asv_605))])
pcoa.table_605$Axis.1
## [1] -0.2890678 -0.3378967 0.1346398 0.3260506 0.3899960 0.3911276
## [7] 0.3776538 -0.3484572 -0.3292667 -0.3147794
# Perform CAP analysis for GDD_5C value 605
cap_result_605 <- capscale(dist.mat_605 ~ 1, data = pcoa.table_605)
# Extract percentage variance explained by each axis
percent_var_explained_605 <- round(cap_result_605$CA$eig/sum(cap_result_605$CA$eig) *
100, 2)
# Print the results for GDD_5C value 605
print(percent_var_explained_605)
## MDS1 MDS2 MDS3 MDS4 MDS5 MDS6 MDS7 MDS8 MDS9
## 29.44 13.42 12.29 11.46 10.54 9.98 7.20 3.15 2.51
#### OR:
# Extract eigenvalues for Axis 1 and Axis 2
eigenvalues_axis1_605 <- pcoa_605$values$Eigenvalues[1]
eigenvalues_axis2_605 <- pcoa_605$values$Eigenvalues[2]
# Calculate the total sum of eigenvalues for normalization
total_eigenvalues_605 <- sum(pcoa_605$values$Eigenvalues)
# Calculate the percentage of variance explained by Axis 1 and Axis 2
variance_explained_axis1_605 <- eigenvalues_axis1_605/total_eigenvalues_605 * 100
variance_explained_axis2_605 <- eigenvalues_axis2_605/total_eigenvalues_605 * 100
# Print the results
print(variance_explained_axis1_605)
## [1] 29.43888
print(variance_explained_axis2_605)
## [1] 13.41991
################################################################################ GDD_1087
asv_1087 <- data_1087[rowSums(data_1087[, grepl("ASV", colnames(data_1087))]) !=
0, ]
distance = "bray"
dist.mat_1087 <- vegan::vegdist(asv_1087[, grepl("ASV", colnames(asv_1087))], method = distance)
pcoa_1087 <- pcoa(dist.mat_1087)
pcoa.table_1087 <- cbind(pcoa_1087$vectors[, 1:5], asv_1087[, !grepl("ASV", colnames(asv_1087))])
pcoa.table_1087$Axis.1
## [1] 0.43250402 -0.25297578 -0.16551807 0.06296132 0.37780717 -0.21590866
## [7] 0.19448435 -0.25914289 0.43702446 -0.33653528 -0.27470064
# Perform CAP analysis for GDD_5C value 1087
cap_result_1087 <- capscale(dist.mat_1087 ~ 1, data = pcoa.table_1087)
# Extract percentage variance explained by each axis
percent_var_explained_1087 <- round(cap_result_1087$CA$eig/sum(cap_result_1087$CA$eig) *
100, 2)
# Print the results for GDD_5C value 1087
print(percent_var_explained_1087)
## MDS1 MDS2 MDS3 MDS4 MDS5 MDS6 MDS7 MDS8 MDS9 MDS10
## 22.25 13.12 11.68 10.88 9.88 8.95 8.45 7.46 4.37 2.96
#### OR:
# Extract eigenvalues for Axis 1 and Axis 2
eigenvalues_axis1_1087 <- pcoa_1087$values$Eigenvalues[1]
eigenvalues_axis2_1087 <- pcoa_1087$values$Eigenvalues[2]
# Calculate the total sum of eigenvalues for normalization
total_eigenvalues_1087 <- sum(pcoa_1087$values$Eigenvalues)
# Calculate the percentage of variance explained by Axis 1 and Axis 2
variance_explained_axis1_1087 <- eigenvalues_axis1_1087/total_eigenvalues_1087 *
100
variance_explained_axis2_1087 <- eigenvalues_axis2_1087/total_eigenvalues_1087 *
100
# Print the results
print(variance_explained_axis1_1087)
## [1] 22.25031
print(variance_explained_axis2_1087)
## [1] 13.11649
################################################################################ GDD_1606
asv_1606 <- data_1606[rowSums(data_1606[, grepl("ASV", colnames(data_1606))]) !=
0, ]
distance = "bray"
dist.mat_1606 <- vegan::vegdist(asv_1606[, grepl("ASV", colnames(asv_1606))], method = distance)
pcoa_1606 <- pcoa(dist.mat_1606)
pcoa.table_1606 <- cbind(pcoa_1606$vectors[, 1:5], asv_1606[, !grepl("ASV", colnames(asv_1606))])
pcoa.table_1606$Axis.1
## [1] 0.3363933 -0.2906700 -0.2842794 -0.2379328 0.2141189 -0.2986424
## [7] 0.3952310 0.2124828 0.2688760 -0.3155773
# Perform CAP analysis for GDD_5C value 1087
cap_result_1606 <- capscale(dist.mat_1606 ~ 1, data = pcoa.table_1606)
# Extract percentage variance explained by each axis
percent_var_explained_1606 <- round(cap_result_1606$CA$eig/sum(cap_result_1606$CA$eig) *
100, 2)
# Print the results for GDD_5C value 1087
print(percent_var_explained_1606)
## MDS1 MDS2 MDS3 MDS4 MDS5 MDS6 MDS7 MDS8 MDS9
## 21.58 14.57 12.20 11.73 11.32 9.31 8.83 6.67 3.77
#### OR:
# Extract eigenvalues for Axis 1 and Axis 2
eigenvalues_axis1_1606 <- pcoa_1606$values$Eigenvalues[1]
eigenvalues_axis2_1606 <- pcoa_1606$values$Eigenvalues[2]
# Calculate the total sum of eigenvalues for normalization
total_eigenvalues_1606 <- sum(pcoa_1606$values$Eigenvalues)
# Calculate the percentage of variance explained by Axis 1 and Axis 2
variance_explained_axis1_1606 <- eigenvalues_axis1_1606/total_eigenvalues_1606 *
100
variance_explained_axis2_1606 <- eigenvalues_axis2_1606/total_eigenvalues_1606 *
100
# Print the results
print(variance_explained_axis1_1606)
## [1] 21.58468
print(variance_explained_axis2_1606)
## [1] 14.56844
################################################################################ GDD_1992
asv_1992 <- data_1992[rowSums(data_1992[, grepl("ASV", colnames(data_1992))]) !=
0, ]
distance = "bray"
dist.mat_1992 <- vegan::vegdist(asv_1992[, grepl("ASV", colnames(asv_1992))], method = distance)
pcoa_1992 <- pcoa(dist.mat_1992)
pcoa.table_1992 <- cbind(pcoa_1992$vectors[, 1:5], asv_1992[, !grepl("ASV", colnames(asv_1992))])
pcoa.table_1992$Axis.1
## [1] -0.2665334 -0.1845988 -0.2384031 -0.0953122 -0.2852400 -0.3715739
## [7] 0.3363458 0.3079164 0.3809448 0.4164545
# Perform CAP analysis for GDD_5C value 1087
cap_result_1992 <- capscale(dist.mat_1992 ~ 1, data = pcoa.table_1992)
# Extract percentage variance explained by each axis
percent_var_explained_1992 <- round(cap_result_1992$CA$eig/sum(cap_result_1992$CA$eig) *
100, 2)
# Print the results for GDD_5C value 1087
print(percent_var_explained_1992)
## MDS1 MDS2 MDS3 MDS4 MDS5 MDS6 MDS7 MDS8 MDS9
## 23.61 14.10 12.14 11.62 10.13 9.20 8.16 7.13 3.91
#### OR:
# Extract eigenvalues for Axis 1 and Axis 2
eigenvalues_axis1_1992 <- pcoa_1992$values$Eigenvalues[1]
eigenvalues_axis2_1992 <- pcoa_1992$values$Eigenvalues[2]
# Calculate the total sum of eigenvalues for normalization
total_eigenvalues_1992 <- sum(pcoa_1992$values$Eigenvalues)
# Calculate the percentage of variance explained by Axis 1 and Axis 2
variance_explained_axis1_1992 <- eigenvalues_axis1_1992/total_eigenvalues_1992 *
100
variance_explained_axis2_1992 <- eigenvalues_axis2_1992/total_eigenvalues_1992 *
100
# Print the results
print(variance_explained_axis1_1992)
## [1] 23.61454
print(variance_explained_axis2_1992)
## [1] 14.09844
################################################################################ GDD_2140
asv_2140 <- data_2140[rowSums(data_2140[, grepl("ASV", colnames(data_2140))]) !=
0, ]
distance = "bray"
dist.mat_2140 <- vegan::vegdist(asv_2140[, grepl("ASV", colnames(asv_2140))], method = distance)
pcoa_2140 <- pcoa(dist.mat_2140)
pcoa.table_2140 <- cbind(pcoa_2140$vectors[, 1:5], asv_2140[, !grepl("ASV", colnames(asv_2140))])
pcoa.table_2140$Axis.1
## [1] 0.3316495 0.3273169 -0.3748007 -0.2548305 -0.4027417 0.2137779
## [7] -0.2181089 0.4242010 0.3395166 -0.3859803
# Perform CAP analysis for GDD_5C value 1087
cap_result_2140 <- capscale(dist.mat_2140 ~ 1, data = pcoa.table_2140)
# Extract percentage variance explained by each axis
percent_var_explained_2140 <- round(cap_result_2140$CA$eig/sum(cap_result_2140$CA$eig) *
100, 2)
# Print the results for GDD_5C value 1087
print(percent_var_explained_2140)
## MDS1 MDS2 MDS3 MDS4 MDS5 MDS6 MDS7 MDS8 MDS9
## 29.79 14.10 12.03 10.53 9.33 8.91 6.08 5.04 4.19
#### OR:
# Extract eigenvalues for Axis 1 and Axis 2
eigenvalues_axis1_2140 <- pcoa_2140$values$Eigenvalues[1]
eigenvalues_axis2_2140 <- pcoa_2140$values$Eigenvalues[2]
# Calculate the total sum of eigenvalues for normalization
total_eigenvalues_2140 <- sum(pcoa_2140$values$Eigenvalues)
# Calculate the percentage of variance explained by Axis 1 and Axis 2
variance_explained_axis1_2140 <- eigenvalues_axis1_2140/total_eigenvalues_2140 *
100
variance_explained_axis2_2140 <- eigenvalues_axis2_2140/total_eigenvalues_2140 *
100
# Print the results
print(variance_explained_axis1_2140)
## [1] 29.79347
print(variance_explained_axis2_2140)
## [1] 14.10168
################################################################################ GDD_2219
asv_2219 <- data_2219[rowSums(data_2219[, grepl("ASV", colnames(data_2219))]) !=
0, ]
distance = "bray"
dist.mat_2219 <- vegan::vegdist(asv_2219[, grepl("ASV", colnames(asv_2219))], method = distance)
pcoa_2219 <- pcoa(dist.mat_2219)
pcoa.table_2219 <- cbind(pcoa_2219$vectors[, 1:5], asv_2219[, !grepl("ASV", colnames(asv_2219))])
pcoa.table_2219$Axis.1
## [1] -0.2511946 0.4076504 0.2408088 0.3760269 -0.4010673 0.3047372
## [7] -0.3581405 -0.3452218 0.4003384 -0.3739376
# Perform CAP analysis for GDD_5C value 1087
cap_result_2219 <- capscale(dist.mat_2219 ~ 1, data = pcoa.table_2219)
# Extract percentage variance explained by each axis
percent_var_explained_2219 <- round(cap_result_2219$CA$eig/sum(cap_result_2219$CA$eig) *
100, 2)
# Print the results for GDD_5C value 1087
print(percent_var_explained_2219)
## MDS1 MDS2 MDS3 MDS4 MDS5 MDS6 MDS7 MDS8 MDS9
## 33.17 14.60 12.61 11.15 9.67 9.03 6.55 2.47 0.75
#### OR:
# Extract eigenvalues for Axis 1 and Axis 2
eigenvalues_axis1_2219 <- pcoa_2219$values$Eigenvalues[1]
eigenvalues_axis2_2219 <- pcoa_2219$values$Eigenvalues[2]
# Calculate the total sum of eigenvalues for normalization
total_eigenvalues_2219 <- sum(pcoa_2219$values$Eigenvalues)
# Calculate the percentage of variance explained by Axis 1 and Axis 2
variance_explained_axis1_2219 <- eigenvalues_axis1_2219/total_eigenvalues_2219 *
100
variance_explained_axis2_2219 <- eigenvalues_axis2_2219/total_eigenvalues_2219 *
100
# Print the results
print(variance_explained_axis1_2219)
## [1] 33.17425
print(variance_explained_axis2_2219)
## [1] 14.60206
library(ggforce)
# Does community composition cluster based on GDD within each species?
pcoa_betula_subset <- pcoa.table_phenology_modified[pcoa.table_phenology_modified$Species ==
"Betula populifolia", ]
pcoa_populus_subset <- pcoa.table_phenology_modified[pcoa.table_phenology_modified$Species ==
"Populus tremuloides", ]
scale_custom_9 <- list(scale_color_manual(values = c("purple", "darkred", "darkblue",
"turquoise", "darkorange", "darkgreen", "magenta", "gold")), scale_fill_manual(values = c("purple",
"darkred", "darkblue", "turquoise", "darkorange", "darkgreen", "magenta", "gold")))
data_betula <- asv_scaled_noPlants_Phen_filt_LMM[asv_scaled_noPlants_Phen_filt_LMM$Species == "Betula_populifolia", ]
asv_betula<-data_betula[rowSums(data_betula[,grepl("ASV", colnames(data_betula))])!=0, ]
distance="bray"
dist.mat_betula <- vegan::vegdist(asv_betula[,grepl("ASV", colnames(asv_betula))], method = distance)
pcoa_betula <- pcoa(dist.mat_betula)
pcoa.table_betula <- cbind(pcoa_betula$vectors[, 1:5], asv_betula[,!grepl("ASV", colnames(asv_betula))])
pcoa.table_betula$Axis.1
## [1] 0.32185084 -0.15542618 0.07119949 0.38373670 0.05637697 0.22631012
## [7] 0.30710593 -0.48474348 0.35024649 0.38398583 -0.38182276 -0.06819215
## [13] -0.13753924 0.37157771 -0.35463606 -0.46884942 0.28697350 0.13971448
## [19] 0.40502434 -0.37168145 0.29766773 -0.34680044 0.34265923 0.07813432
## [25] -0.39687777 0.04950438 -0.03379417 -0.30411283 0.17149765 -0.35018965
## [31] -0.23630624 0.36823035 -0.40533706 -0.23225121 0.11676406
# Define the sampling points for GDD
sampling_points <- c(437, 605, 1087, 1606, 1992, 2140, 2219)
###############################################################################
## BETULA BETA DIV PCoA
###############################################################################
# Define custom shapes for each unique GDD_5C_bins value
shapes <- c(21, 22, 23, 18, 17, 15, 8) # Example shapes
# Define custom colors for each unique GDD_5C_bins value
colors <- c("royalblue", "cyan4", "goldenrod2")
pcoa.table_betula$Phen_Period <- cut(pcoa.table_betula$GDD_5C,
breaks = c(-Inf, 1087, 1992, Inf),
labels = c("Early-Mid", "Mid-Late", "Late-Senescence"),
include.lowest = TRUE,
right = FALSE
)
betula_beta_pcoa_intra_phen <- ggplot(pcoa.table_betula, aes(x = Axis.1, y = Axis.2)) +
geom_point(aes(color = Phen_Period, shape = GDD_5C_bins), size = 3) + # Use the new Season variable
stat_ellipse(aes(color = Phen_Period), level = 0.95, linetype = "dashed") + # Add ellipses
labs(color = "General Phenological Period", # Updated legend
shape = expression("GDD (" * T[base] * " = 5"~degree*C * ")"), # Updated legend
x = "Axis 1 [25.98%]", y = "Axis 2 [11.26%]") +
guides(color = guide_legend(order = 1),
shape = guide_legend(order = 1)) +
scale_shape_manual(values = shapes) + # Define shapes for season
scale_color_manual(values = c("royalblue", "cyan4", "goldenrod2")) + # Define colors for season
theme_cowplot(12) +
theme(
axis.title.x = element_text(size = 8),
axis.title.y = element_text(size = 8),
axis.text.x = element_text(size = 6),
axis.text.y = element_text(size = 6),
legend.title = element_text(size = 8),
legend.text = element_text(size = 8),
panel.border = element_rect(color = "black", size = 1, fill = NA),
axis.ticks = element_line(color = "black")
)
betula_beta_pcoa_intra_phen
## WITHOUT PHEN PERIODS!
# Define custom colors for each unique GDD_5C_bins value
colors <- c("darkmagenta","orangered2","cyan4","orange","yellow3","royalblue3", "hotpink")
betula_beta_pcoa_intra_gdds <- ggplot(pcoa.table_betula, aes(x = Axis.1, y = Axis.2)) +
geom_point(aes(color = GDD_5C_bins), size = 3) +
# stat_ellipse(aes(color = Phen_Period), level = 0.95, linetype = "dashed") + # Add ellipses
labs(color = expression("GDD (" * T[base] * " = 5"~degree*C * ")"), # Updated legend
x = "Axis 1 [25.98%]", y = "Axis 2 [11.26%]") +
guides(color = guide_legend(order = 1)) +
# scale_shape_manual(values = shapes) + # Define shapes for season
scale_color_manual(values = colors) +
theme_cowplot(12) +
theme(
axis.title.x = element_text(size = 8),
axis.title.y = element_text(size = 8),
axis.text.x = element_text(size = 6),
axis.text.y = element_text(size = 6),
legend.title = element_text(size = 8),
legend.text = element_text(size = 8),
panel.border = element_rect(color = "black", size = 1, fill = NA),
axis.ticks = element_line(color = "black")
)
betula_beta_pcoa_intra_gdds
colors <- c("darkmagenta","orangered2","darkgreen","orange","chocolate4","royalblue3", "hotpink")
betula_beta_pcoa_intra_gdds2 <- ggplot(pcoa.table_betula, aes(x = Axis.1, y = Axis.2)) +
geom_point(aes(color = GDD_5C_bins, shape = GDD_5C_bins), size = 3) + # color and shape both by GDD bin
stat_ellipse(aes(color = GDD_5C_bins), level = 0.95, linetype = "dashed") + # Ellipses now by GDD bin
labs(color = expression("GDD (" * T[base] * " = 5"~degree*C * ")"), # Updated legend title
shape = expression("GDD (" * T[base] * " = 5"~degree*C * ")"),
x = "Axis 1 [25.98%]", y = "Axis 2 [11.26%]") +
guides(color = guide_legend(order = 1),
shape = guide_legend(order = 1)) +
scale_shape_manual(values = shapes) +
scale_color_manual(values = colors) + # Use the custom GDD bin colors you defined
theme_cowplot(12) +
theme(
axis.title.x = element_text(size = 8),
axis.title.y = element_text(size = 8),
axis.text.x = element_text(size = 6),
axis.text.y = element_text(size = 6),
legend.title = element_text(size = 8),
legend.text = element_text(size = 8),
panel.border = element_rect(color = "black", size = 1, fill = NA),
axis.ticks = element_line(color = "black")
)
betula_beta_pcoa_intra_gdds2
# CAP Analysis for percent variance
cap_result_betula <- capscale(dist.mat_betula ~ 1, data = pcoa.table_betula)
percent_var_explained_betula <- round(cap_result_betula$CA$eig/sum(cap_result_betula$CA$eig) *
100, 2)
print(percent_var_explained_betula)
## MDS1 MDS2 MDS3 MDS4 MDS5 MDS6 MDS7 MDS8 MDS9 MDS10 MDS11 MDS12 MDS13
## 25.94 11.24 8.59 6.19 4.56 4.36 3.72 3.60 3.42 3.25 2.97 2.57 2.36
## MDS14 MDS15 MDS16 MDS17 MDS18 MDS19 MDS20 MDS21 MDS22 MDS23 MDS24 MDS25 MDS26
## 2.00 1.99 1.68 1.61 1.47 1.24 1.10 0.97 0.90 0.76 0.75 0.70 0.49
## MDS27 MDS28 MDS29 MDS30 MDS31 MDS32
## 0.43 0.35 0.30 0.22 0.15 0.12
# OR, likely better for PCoA:
# Extract eigenvalues for Axis 1 and Axis 2
eigenvalues_axis1_betula <- pcoa_betula$values$Eigenvalues[1]
eigenvalues_axis2_betula <- pcoa_betula$values$Eigenvalues[2]
# Calculate the total sum of eigenvalues for normalization
total_eigenvalues_betula <- sum(pcoa_betula$values$Eigenvalues)
# Calculate the percentage of variance explained by Axis 1 and Axis 2
variance_explained_axis1_betula <- eigenvalues_axis1_betula/total_eigenvalues_betula *
100
variance_explained_axis2_betula <- eigenvalues_axis2_betula/total_eigenvalues_betula *
100
# Print the results
print(variance_explained_axis1_betula)
## [1] 25.97772
print(variance_explained_axis2_betula)
## [1] 11.25663
# Save the plot as a JPEG image
ggsave(filename = "Betula_pcoa_gdds_season.jpeg", plot = betula_pcoa_plot_season,
device = "jpeg", width = 12, height = 8, units = "in")
library(urca)
kpss_beta_betula_axis1 <- ur.kpss(pcoa.table_betula$Axis.1)
kpss_beta_betula_axis1 <- ur.kpss(pcoa.table_phenology_filtered$Axis.1[asv_scaled_noPlants_Phen_filt_LMM$Species ==
"Betula_populifolia"])
summary(kpss_beta_betula_axis1)
##
## #######################
## # KPSS Unit Root Test #
## #######################
##
## Test is of type: mu with 3 lags.
##
## Value of test-statistic is: 0.2677
##
## Critical value for a significance level of:
## 10pct 5pct 2.5pct 1pct
## critical values 0.347 0.463 0.574 0.739
# Overall, Axis 1 of Betula beta div PCoA is STATIONARY!
kpss_beta_betula_axis2 <- ur.kpss(pcoa.table_betula$Axis.2)
kpss_beta_betula_axis2 <- ur.kpss(pcoa.table_phenology_filtered$Axis.2[asv_scaled_noPlants_Phen_filt_LMM$Species ==
"Betula_populifolia"])
summary(kpss_beta_betula_axis2)
##
## #######################
## # KPSS Unit Root Test #
## #######################
##
## Test is of type: mu with 3 lags.
##
## Value of test-statistic is: 0.4296
##
## Critical value for a significance level of:
## 10pct 5pct 2.5pct 1pct
## critical values 0.347 0.463 0.574 0.739
# Overall, Axis 2 of Betula beta div PCoA is STATIONARY!
data_populus <- asv_scaled_noPlants_Phen_filt_LMM[asv_scaled_noPlants_Phen_filt_LMM$Species == "Populus_tremuloides", ]
asv_populus<-data_populus[rowSums(data_populus[,grepl("ASV", colnames(data_populus))])!=0, ]
distance="bray"
dist.mat_populus <- vegan::vegdist(asv_populus[,grepl("ASV", colnames(asv_populus))], method = distance)
pcoa_populus <- pcoa(dist.mat_populus)
pcoa.table_populus <- cbind(pcoa_populus$vectors[, 1:5], asv_populus[,!grepl("ASV", colnames(asv_populus))])
pcoa.table_populus$Axis.1
## [1] 0.264271426 0.060279730 0.073692690 0.110784243 -0.059836302
## [6] 0.243980186 0.197052405 0.160926482 -0.037283798 0.058222492
## [11] 0.134516141 -0.102407686 -0.062668510 0.137074869 0.004128356
## [16] 0.106592222 -0.383186479 0.056580432 0.108662063 -0.176767075
## [21] 0.229669966 -0.347136308 0.008312481 -0.172540180 -0.247250789
## [26] 0.174599804 -0.250380029 0.015794125 -0.135971520 -0.030012080
## [31] 0.060872084 -0.201046955 0.325211607 0.104412843 -0.320320207
## [36] -0.108828730
# Define the sampling points for GDD
sampling_points <- c(437, 605, 1087, 1606, 1992, 2140, 2219)
# Define custom shapes for each unique GDD_5C_bins value
shapes <- c(21, 22, 23, 18, 17, 15, 8) # Example shapes
# Define custom colors for each unique GDD_5C_bins value
colors <- c("royalblue", "cyan4", "goldenrod2")
pcoa.table_populus$Phen_Period <- cut(pcoa.table_populus$GDD_5C,
breaks = c(-Inf, 1087, 1992, Inf),
labels = c("Early-Mid", "Mid-Late", "Late-Senescence"),
include.lowest = TRUE,
right = FALSE
)
populus_beta_pcoa_intra_phen <- ggplot(pcoa.table_populus, aes(x = Axis.1, y = Axis.2)) +
geom_point(aes(color = Phen_Period, shape = GDD_5C_bins), size = 3) + # Use the new Season variable
stat_ellipse(aes(color = Phen_Period), level = 0.95, linetype = "dashed") + # Add ellipses
labs(color = "General Phenological Period", # Updated legend
shape = expression("GDD (" * T[base] * " = 5"~degree*C * ")"), # Updated legend
x = "Axis 1 [7.54%]", y = "Axis 2 [5.96%]") +
guides(color = guide_legend(order = 1),
shape = guide_legend(order = 1)) +
scale_shape_manual(values = shapes) + # Define shapes for season
scale_color_manual(values = c("royalblue", "cyan4", "goldenrod2")) + # Define colors for season
theme_cowplot(12) +
theme(
axis.title.x = element_text(size = 8),
axis.title.y = element_text(size = 8),
axis.text.x = element_text(size = 6),
axis.text.y = element_text(size = 6),
legend.title = element_text(size = 8),
legend.text = element_text(size = 8),
panel.border = element_rect(color = "black", size = 1, fill = NA),
axis.ticks = element_line(color = "black")
)
populus_beta_pcoa_intra_phen
# Define custom colors for each unique GDD_5C_bins value
colors <- c("darkmagenta","orangered2","cyan4","orange","yellow3","royalblue3", "hotpink")
populus_beta_pcoa_intra_gdds <- ggplot(pcoa.table_populus, aes(x = Axis.1, y = Axis.2)) +
geom_point(aes(color = GDD_5C_bins), size = 3) +
# stat_ellipse(aes(color = Phen_Period), level = 0.95, linetype = "dashed") + # Add ellipses
labs(color = expression("GDD (" * T[base] * " = 5"~degree*C * ")"), # Updated legend
x = "Axis 1 [7.54%]", y = "Axis 2 [5.96%]") +
guides(color = guide_legend(order = 1),
shape = guide_legend(order = 1)) +
# scale_shape_manual(values = shapes) + # Define shapes for season
scale_color_manual(values = colors) +
theme_cowplot(12) +
theme(
axis.title.x = element_text(size = 8),
axis.title.y = element_text(size = 8),
axis.text.x = element_text(size = 6),
axis.text.y = element_text(size = 6),
legend.title = element_text(size = 8),
legend.text = element_text(size = 8),
panel.border = element_rect(color = "black", size = 1, fill = NA),
axis.ticks = element_line(color = "black")
)
populus_beta_pcoa_intra_gdds
colors <- c("darkmagenta","orangered2","darkgreen","orange","chocolate4","royalblue3", "hotpink")
populus_beta_pcoa_intra_gdds2 <- ggplot(pcoa.table_populus, aes(x = Axis.1, y = Axis.2)) +
geom_point(aes(color = GDD_5C_bins, shape = GDD_5C_bins), size = 3) + # color and shape both by GDD bin
stat_ellipse(aes(color = GDD_5C_bins), level = 0.95, linetype = "dashed") + # Ellipses now by GDD bin
labs(color = expression("GDD (" * T[base] * " = 5"~degree*C * ")"), # Updated legend title
shape = expression("GDD (" * T[base] * " = 5"~degree*C * ")"),
x = "Axis 1 [7.54%]", y = "Axis 2 [5.96%]") +
guides(color = guide_legend(order = 1),
shape = guide_legend(order = 1)) +
scale_shape_manual(values = shapes) +
scale_color_manual(values = colors) + # Use the custom GDD bin colors you defined
theme_cowplot(12) +
theme(
axis.title.x = element_text(size = 8),
axis.title.y = element_text(size = 8),
axis.text.x = element_text(size = 6),
axis.text.y = element_text(size = 6),
legend.title = element_text(size = 8),
legend.text = element_text(size = 8),
panel.border = element_rect(color = "black", size = 1, fill = NA),
axis.ticks = element_line(color = "black")
)
populus_beta_pcoa_intra_gdds2
# CAP Analysis for percent variance
cap_result_populus <- capscale(dist.mat_populus ~ 1, data = pcoa.table_populus)
percent_var_explained_populus <- round(cap_result_populus$CA$eig/sum(cap_result_populus$CA$eig) *
100, 2)
print(percent_var_explained_populus)
## MDS1 MDS2 MDS3 MDS4 MDS5 MDS6 MDS7 MDS8 MDS9 MDS10 MDS11 MDS12 MDS13
## 7.54 5.96 4.85 4.50 4.23 4.05 3.88 3.74 3.64 3.50 3.32 3.23 2.94
## MDS14 MDS15 MDS16 MDS17 MDS18 MDS19 MDS20 MDS21 MDS22 MDS23 MDS24 MDS25 MDS26
## 2.93 2.83 2.69 2.58 2.57 2.46 2.40 2.29 2.26 2.11 2.03 2.02 1.89
## MDS27 MDS28 MDS29 MDS30 MDS31 MDS32 MDS33 MDS34 MDS35
## 1.82 1.80 1.77 1.60 1.56 1.46 1.24 1.20 1.09
# OR, likely better for PCoA:
# Extract eigenvalues for Axis 1 and Axis 2
eigenvalues_axis1_populus <- pcoa_populus$values$Eigenvalues[1]
eigenvalues_axis2_populus <- pcoa_populus$values$Eigenvalues[2]
# Calculate the total sum of eigenvalues for normalization
total_eigenvalues_populus <- sum(pcoa_populus$values$Eigenvalues)
# Calculate the percentage of variance explained by Axis 1 and Axis 2
variance_explained_axis1_populus <- eigenvalues_axis1_populus/total_eigenvalues_populus *
100
variance_explained_axis2_populus <- eigenvalues_axis2_populus/total_eigenvalues_populus *
100
# Print the results
print(variance_explained_axis1_populus)
## [1] 7.53663
print(variance_explained_axis2_populus)
## [1] 5.95548
# Save the plot as a JPEG image
ggsave(filename = "Populus_pcoa_gdds.jpeg", plot = populus_pcoa_plot_season, device = "jpeg",
width = 12, height = 8, units = "in")
## WITH GENERAL PHEN PERIODS:
library(gridExtra)
library(grid)
# Arrange the plots in a grid with labels
betaDiv_intra_combined_phen <- arrangeGrob(grobs = list(arrangeGrob(betula_beta_pcoa_intra_phen,
top = textGrob("a", x = unit(0, "npc"), y = unit(1, "npc"), just = c("left",
"top"), gp = gpar(fontsize = 30, fontface = "bold"))), arrangeGrob(populus_beta_pcoa_intra_phen,
top = textGrob("b", x = unit(0, "npc"), y = unit(1, "npc"), just = c("left",
"top"), gp = gpar(fontsize = 30, fontface = "bold")))), ncol = 1, nrow = 2)
# Save
ggsave("betaDiv_intra_combined_phen.jpg", betaDiv_intra_combined_phen, width = 7,
height = 7)
# Save `asv_scaled_noPlants_Phen_filt_LMM`
write.csv(asv_scaled_noPlants_Phen_filt_LMM, file = "asv_scaled_noPlants_Phen_filt_LMM.csv",
row.names = FALSE)
kpss_beta_populus_axis1 <- ur.kpss(pcoa.table_populus$Axis.1)
kpss_beta_populus_axis1 <- ur.kpss(pcoa.table_phenology_filtered$Axis.1[asv_scaled_noPlants_Phen_filt_LMM$Species ==
"Populus_tremuloides"])
summary(kpss_beta_populus_axis1)
##
## #######################
## # KPSS Unit Root Test #
## #######################
##
## Test is of type: mu with 3 lags.
##
## Value of test-statistic is: 0.5871
##
## Critical value for a significance level of:
## 10pct 5pct 2.5pct 1pct
## critical values 0.347 0.463 0.574 0.739
# NOTE: Axis 1 of Populus beta div PCoA is NON-STATIONARY**
kpss_beta_populus_axis2 <- ur.kpss(pcoa.table_populus$Axis.2)
kpss_beta_populus_axis2 <- ur.kpss(pcoa.table_phenology_filtered$Axis.2[asv_scaled_noPlants_Phen_filt_LMM$Species ==
"Populus_tremuloides"])
summary(kpss_beta_populus_axis2)
##
## #######################
## # KPSS Unit Root Test #
## #######################
##
## Test is of type: mu with 3 lags.
##
## Value of test-statistic is: 0.19
##
## Critical value for a significance level of:
## 10pct 5pct 2.5pct 1pct
## critical values 0.347 0.463 0.574 0.739
# Overall, Axis 2 of Populus beta div PCoA is STATIONARY!
tx <- as.data.frame(taxa_rdp[rownames(taxa_rdp) %in% colnames(asv_scaled_noPlants_Phen_filt_LMM),
])
head(tx)
## Kingdom Phylum Class Order
## ASV7 Bacteria Proteobacteria Alphaproteobacteria Acetobacterales
## ASV8 Bacteria Proteobacteria Alphaproteobacteria Acetobacterales
## ASV9 Bacteria Proteobacteria Alphaproteobacteria Rhizobiales
## ASV10 Bacteria Proteobacteria <NA> <NA>
## ASV12 Bacteria Firmicutes Bacilli Staphylococcales
## ASV13 Bacteria Firmicutes Bacilli Lactobacillales
## Family Genus Species
## ASV7 Acetobacteraceae Endobacter <NA>
## ASV8 Acetobacteraceae Endobacter <NA>
## ASV9 Beijerinckiaceae 1174-901-12 <NA>
## ASV10 <NA> <NA> <NA>
## ASV12 Staphylococcaceae Staphylococcus <NA>
## ASV13 Lactobacillaceae Limosilactobacillus <NA>
taxaLevel = "Genus"
asv_data = asv_scaled_noPlants_Phen_filt_LMM
asv_data$Species <- as.character(asv_data$Species)
# Filter data by species
data_betula <- subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia")
data_populus <- subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides")
library(phyloseq)
#--------------------------------------------------
# FOR `asv_scaled_noPlants_Phenology_filtered`:
#--------------------------------------------------
# tx_data <- as.data.frame(tx)
meta_stats <- data.frame(meta)
asv_scaled_noPlants_Phenology_stats <- data.frame(asv_scaled_noPlants_Phenology_filtered)
# Add the '_R1_F_filt.fastq' suffix to the 'Name' column to create the
# 'SampleID' column
meta_stats$SampleID <- paste0(meta_stats$Name, "_R1_F_filt.fastq")
asv_scaled_noPlants_Phenology_stats$SampleID <- paste0(asv_scaled_noPlants_Phenology_stats$Name,
"_R1_F_filt.fastq")
# Set the 'SampleID' column as the row names of the meta_stats data frame
rownames(meta_stats) <- meta_stats$SampleID
rownames(asv_scaled_noPlants_Phenology_stats) <- asv_scaled_noPlants_Phenology_stats$SampleID
# Remove the 'SampleID' column since it is now used as row names
# meta_stats$SampleID <- NULL asv_scaled_noPlants_Phenology_stats$SampleID <-
# NULL
#--------------------------------------------------
# FOR `asv_scaled_noPlants_Phen_filt_LMM`:
#--------------------------------------------------
# tx_data <- as.data.frame(tx)
meta_stats <- data.frame(meta)
asv_scaled_noPlants_Phen_filt_LMM$Phenology <- factor(case_when(asv_scaled_noPlants_Phen_filt_LMM$GDD_5C %in%
c(437, 605, 1087) ~ "Early", asv_scaled_noPlants_Phen_filt_LMM$GDD_5C %in% c(1606,
1992) ~ "Mid", asv_scaled_noPlants_Phen_filt_LMM$GDD_5C %in% c(2140, 2219) ~
"Late"), levels = c("Early", "Mid", "Late"))
asv_scaled_noPlants_Phenology_stats_LMM <- data.frame(asv_scaled_noPlants_Phen_filt_LMM)
# Add the '_R1_F_filt.fastq' suffix to the 'Name' column to create the
# 'SampleID' column
meta_stats$SampleID <- paste0(meta_stats$Name, "_R1_F_filt.fastq")
asv_scaled_noPlants_Phenology_stats_LMM$SampleID <- paste0(asv_scaled_noPlants_Phenology_stats_LMM$Name,
"_R1_F_filt.fastq")
# Set the 'SampleID' column as the row names of the meta_stats data frame
rownames(meta_stats) <- meta_stats$SampleID
rownames(asv_scaled_noPlants_Phenology_stats_LMM) <- asv_scaled_noPlants_Phenology_stats_LMM$SampleID
# Remove the 'SampleID' column since it is now used as row names
# meta_stats$SampleID <- NULL asv_scaled_noPlants_Phenology_stats$SampleID <-
# NULL
# Copy the numeric 'GDD_5C' column to a new factor 'GDD_5C_categ' column
asv_scaled_noPlants_Phen_filt_LMM$GDD_5C_categ <- as.factor(asv_scaled_noPlants_Phen_filt_LMM$GDD_5C)
taxaMat <- as.matrix(tx)
# Create `phyloseq` object (with `meta_stats`)
ps_phen <- phyloseq(otu_table(seqtab.print, taxa_are_rows = FALSE), sample_data(meta_stats),
tax_table(taxaMat))
# Create `phyloseq` object (with `asv_scaled_noPlants_Phenology_stats`)
ps_phen_asv <- phyloseq(otu_table(seqtab.print, taxa_are_rows = FALSE), sample_data(asv_scaled_noPlants_Phenology_stats),
tax_table(taxaMat))
ps_phen_asv_LMM <- phyloseq(otu_table(seqtab.print, taxa_are_rows = FALSE), sample_data(asv_scaled_noPlants_Phenology_stats_LMM),
tax_table(taxaMat))
################################################################################ BOTH
################################################################################ SPECIES
################################################################################ COMBINED/OVERALL
################################################################################ VIEW
ps_relabund1 = transform_sample_counts(ps_phen_asv_LMM, function(x) {
x/sum(x)
})
ps_relabund2 = transform_sample_counts(ps_phen_asv_LMM, function(x) x/sum(x))
ps_relabund_phyla <- tax_glom(ps_phen_asv_LMM, "Phylum")
ps0_relabund_phyla <- transform_sample_counts(ps_relabund_phyla, function(x) x/sum(x))
ps1_relabund_phyla <- merge_samples(ps0_relabund_phyla, "sample_id")
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
ps2_relabund_phyla <- transform_sample_counts(ps1_relabund_phyla, function(x) x/sum(x))
ps_phyla <- tax_glom(ps_phen_asv_LMM, "Phylum")
ps0_phyla <- transform_sample_counts(ps_phyla, function(x) x/sum(x))
ps1_phyla <- merge_samples(ps0_phyla, "GDD_5C_bins")
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
ps2_phyla <- transform_sample_counts(ps1_phyla, function(x) x/sum(x))
# Create a bar plot
combined_composition_gdd_phyla <- plot_bar(ps2_phyla, x = "GDD_5C_bins", fill = "Phylum") +
labs(title = "Combined Taxonomic Abundance", x = "Growing Degree Days (5°C)",
y = "% Relative Abundance")
## Warning in psmelt(physeq): The sample variables:
## Species
## have been renamed to:
## sample_Species
## to avoid conflicts with taxonomic rank names.
# Print the bar plot
print(combined_composition_gdd_phyla)
# library(microshades)
library(phyloseq)
# library(speedyseq)
library(ggplot2)
library(dplyr)
library(cowplot)
library(patchwork)
##
## Attaching package: 'patchwork'
## The following object is masked from 'package:MASS':
##
## area
## The following object is masked from 'package:cowplot':
##
## align_plots
library(forcats)
library(tidyverse)
### Taxonomic Abundance for Betula populifolia (PHYLUM)
# Assuming GDD_5C is a numeric variable in your sample data
subset_ps_betula <- subset_samples(ps_phen_asv_LMM, Species == "Betula_populifolia")
# taxa <- as.data.frame(tax_table(ps_phen_asv_LMM))
# taxa$Genus[is.na(taxa$Genus) | taxa$Genus == '' | taxa$Genus == 'uncultured
# bacterium'] <- 'Unknown' tax_table(ps_phen_asv_LMM) <-
# tax_table(as.matrix(taxa))
ps_bet_phy <- tax_glom(subset_ps_betula, "Phylum")
ps0_bet_phy <- transform_sample_counts(ps_bet_phy, function(x) x/sum(x))
ps1_bet_phy <- merge_samples(ps0_bet_phy, "GDD_5C_bins")
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
ps2_bet_phy <- transform_sample_counts(ps1_bet_phy, function(x) x/sum(x))
# Manually restore GDD_5C_bins to sample_data
sample_data(ps2_bet_phy)$GDD_5C_bins <- factor(rownames(sample_data(ps2_bet_phy)),
levels = c("437", "605", "1087", "1606", "1992", "2140", "2219"))
# Create a bar plot
betula_composition_gdd_phyla2 <- plot_bar(ps2_bet_phy, x = "GDD_5C_bins", fill = "Phylum") +
labs(x = expression("Growing Degree Days (" * T[base] * " = 5" ~ degree * C *
")"), y = "Relative Abundance") + theme(axis.title.x = element_text(size = 8),
axis.title.y = element_text(size = 8), axis.text.x = element_text(size = 6),
axis.text.y = element_text(size = 6), legend.title = element_text(size = 8),
legend.text = element_text(size = 8), panel.border = element_rect(color = "black",
size = 1, fill = NA), axis.ticks = element_line(color = "black")) + guides(fill = guide_legend(keyheight = 0.75,
keywidth = 0.75, ncol = 1))
## Warning in psmelt(physeq): The sample variables:
## Species
## have been renamed to:
## sample_Species
## to avoid conflicts with taxonomic rank names.
# Print the bar plot
print(betula_composition_gdd_phyla2)
ggsave("betula_comp_gdd_phyla2.png", plot = betula_composition_gdd_phyla2, width = 10,
height = 6, units = "in", dpi = 300)
################################################################################ BETULA
################################################################################ ORDERS
################################################################################ (ACROSS
################################################################################ GDDs)
# Subset the phyloseq object for Betula_populifolia
subset_ps_betula <- subset_samples(ps_phen_asv_LMM, Species == "Betula_populifolia")
# Create a bar plot for Betula_populifolia
betula_composition_gdd_order <- plot_bar(subset_ps_betula, x = "GDD_5C_bins", fill = "Order") +
labs(title = "Taxonomic Abundance for Betula populifolia", x = "Growing Degree Days (5°C)")
betula_composition_gdd_order
# Assuming GDD_5C is a numeric variable in your sample data
subset_ps_betula <- subset_samples(ps_phen_asv_LMM, Species == "Betula_populifolia")
ps_bet_ord <- tax_glom(subset_ps_betula, "Order")
ps0_bet_ord <- transform_sample_counts(ps_bet_ord, function(x) x/sum(x))
ps1_bet_ord <- merge_samples(ps0_bet_ord, "GDD_5C_bins")
ps2_bet_ord <- transform_sample_counts(ps1_bet_ord, function(x) x/sum(x))
# Create a bar plot
betula_composition_gdd_order2 <- plot_bar(ps2_bet_ord, x = "GDD_5C_bins", fill = "Order") +
labs(title = "Taxonomic Abundance for Betula populifolia", x = "Growing Degree Days (5°C)",
y = "% Relative Abundance")
# Print the bar plot
print(betula_composition_gdd_order2)
################################################################################ BETULA
################################################################################ FAMILIESS
################################################################################ (ACROSS
################################################################################ GDDs)
# Subset the phyloseq object for Betula_populifolia
subset_ps_betula <- subset_samples(ps_phen_asv_LMM, Species == "Betula_populifolia")
# Create a bar plot for Betula_populifolia
betula_composition_gdd_fam <- plot_bar(subset_ps_betula, x = "GDD_5C_bins", fill = "Family") +
labs(title = "Taxonomic Abundance for Betula populifolia", x = "Growing Degree Days (5°C)")
betula_composition_gdd_fam
# Assuming GDD_5C is a numeric variable in your sample data
subset_ps_betula <- subset_samples(ps_phen_asv_LMM, Species == "Betula_populifolia")
ps_bet_fam <- tax_glom(subset_ps_betula, "Family")
ps0_bet_fam <- transform_sample_counts(ps_bet_fam, function(x) x/sum(x))
ps1_bet_fam <- merge_samples(ps0_bet_fam, "GDD_5C_bins")
ps2_bet_fam <- transform_sample_counts(ps1_bet_fam, function(x) x/sum(x))
# Create a bar plot
betula_composition_gdd_fam2 <- plot_bar(ps2_bet_fam, x = "GDD_5C_bins", fill = "Family",
facet_grid = ~Phylum) + labs(title = "Taxonomic Abundance for Betula populifolia",
x = "Growing Degree Days (5°C)", y = "% Relative Abundance") + theme(legend.position = "bottom")
# Print the bar plot
print(betula_composition_gdd_fam2)
################################################################################ Rel
################################################################################ Abundance
################################################################################ for
################################################################################ Betula
################################################################################ GENERA
library(phyloseq)
library(ggplot2)
library(dplyr)
# Assuming GDD_5C is a numeric variable in your sample data
subset_ps_betula <- subset_samples(ps_phen_asv_LMM, Species == "Betula_populifolia")
# Aggregate at the Genus level
ps_bet_gen2 <- tax_glom(subset_ps_betula, "Genus")
# Transform to relative abundances
ps0_bet_gen2 <- transform_sample_counts(ps_bet_gen2, function(x) x/sum(x))
# Summarize the abundance of each genus across all samples
genus_abundance <- taxa_sums(ps0_bet_gen2)
genus_abundance_df <- data.frame(Genus = names(genus_abundance), Abundance = genus_abundance)
genus_colors_relabund <- c(`NA` = "darkgrey", Unknown = "darkgrey", `1174-901-12` = "lightsalmon",
Abditibacterium = "lightpink3", Acidiphilium = "sienna3", Actinomycetospora = "coral2",
Alteribacillus = "darkorange", Amnibacterium = "goldenrod3", Bradyrhizobium = "gold2",
Bryocella = "burlywood3", Corynebacterium = "lightgoldenrod3", Curtobacterium = "olivedrab",
Dermacoccus = "palegreen", Endobacter = "olivedrab3", Ensifer = "darkolivegreen2",
Hymenobacter = "limegreen", Massilia = "springgreen2", `Methylobacterium-Methylorubrum` = "aquamarine",
Methylocella = "turquoise", Micrococcus = "cyan", Nocardioides = "skyblue", `P3OB-42` = "deepskyblue",
Pelomonas = "blue3", Prauserella = "midnightblue", Pseudomonas = "steelblue",
Quadrisphaera = "lightslateblue", Robbsia = "blueviolet", Rubellimicrobium = "darkorchid",
Roseomonas = "darkmagenta", Rubrobacter = "mediumorchid2", Sphingomonas = "magenta",
Spirosoma = "violetred", Staphylococcus = "deeppink", Streptococcus = "maroon")
# Sort genera by abundance and select the top genera
top_n <- 20 # Change this to the number of top genera you want to plot
top_genera <- genus_abundance_df %>%
arrange(desc(Abundance)) %>%
head(top_n) %>%
pull(Genus)
# Filter the phyloseq object to keep only the top genera
ps0_bet_gen2 <- prune_taxa(top_genera, ps0_bet_gen2)
# Merge samples based on GDD_5C_bins
ps1_bet_gen2 <- merge_samples(ps0_bet_gen2, "GDD_5C_bins")
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
# Manually restore GDD_5C_bins to sample_data
sample_data(ps1_bet_gen2)$GDD_5C_bins <- factor(rownames(sample_data(ps1_bet_gen2)),
levels = c("437", "605", "1087", "1606", "1992", "2140", "2219"))
# Transform to relative abundances again after merging
ps2_bet_gen2 <- transform_sample_counts(ps1_bet_gen2, function(x) x/sum(x))
library(ggplot2)
library(patchwork)
# Get GDD bin levels
gdd_levels <- levels(sample_data(ps2_bet_gen2)$GDD_5C_bins)
x_start <- 0.5
x_end <- length(gdd_levels) + 0.5
# Title bar plot with top and side borders only
betula_title_bar <- ggplot() +
# Background grey rectangle
geom_rect(aes(xmin = x_start, xmax = x_end, ymin = 0.5, ymax = 0.75),
fill = "grey90", color = NA) +
# Top border
geom_segment(aes(x = x_start, xend = x_end, y = 0.75, yend = 0.75), color = "black", linewidth = 0.6) +
# Left border
geom_segment(aes(x = x_start, xend = x_start, y = 0.5, yend = 0.75), color = "black", linewidth = 0.6) +
# Right border
geom_segment(aes(x = x_end, xend = x_end, y = 0.5, yend = 0.75), color = "black", linewidth = 0.6) +
# Centered title text
annotate("text", x = median(seq_along(gdd_levels)), y = 0.61,
label = expression("bold('Grey Birch')"), parse = TRUE, size = 3) +
scale_x_continuous(expand = c(0, 0), limits = c(x_start, x_end)) +
scale_y_continuous(limits = c(0.5, 1.2), expand = c(0, 0)) +
coord_cartesian(clip = "off") +
theme_void() +
theme(
plot.margin = ggplot2::unit(c(0, 0.1, 0, 0.1), "pt")
)
# Actual bar plot
betula_composition_gdd_gen3 <- plot_bar(ps2_bet_gen2, x = "GDD_5C_bins", fill = "Genus") +
labs(x = expression("Growing Degree Days (" * T[base] * " = 5"~degree*C * ")"), y = "Relative Abundance") +
scale_fill_manual(
values = genus_colors_relabund,
labels = function(x) {
str_replace(x, "Methylobacterium-Methylorubrum", "Methylobacterium-\nMethylorubrum")
}
) +
scale_y_continuous(limits = c(0, 1.001), expand = c(0, 0)) +
guides(fill = guide_legend(keyheight = 0.5, keywidth = 0.5)) +
theme(
axis.title.x = element_text(size = 6),
axis.title.y = element_text(size = 6),
axis.text.x = element_text(size = 6, angle = 0, hjust = 0.5),
axis.text.y = element_text(size = 6),
legend.title = element_text(size = 6),
legend.text = element_text(size = 5),
legend.box.margin = margin(0, 0, 0, -10, unit = "pt"),
panel.border = element_rect(color = "black", size = 1, fill = NA),
axis.ticks = element_line(color = "black"),
plot.margin = unit(c(0, 0, 0, 0), "pt"),
panel.grid = element_blank(),
panel.background = element_rect(fill = "white", color = NA)
)
## Warning in psmelt(physeq): The sample variables:
## Species
## have been renamed to:
## sample_Species
## to avoid conflicts with taxonomic rank names.
# Combine the title bar and the actual plot
betula_gen_composition_final <- betula_title_bar / betula_composition_gdd_gen3 +
plot_layout(heights = c(0.12, 1)) & # apply theme to both
theme(
plot.margin = ggplot2::unit(c(0, 0, 0, 0), "pt")
)
betula_gen_composition_final
## Warning in is.na(x): is.na() applied to non-(list or vector) of type
## 'expression'
# Arrange the plots in a grid
betula_gen_phy_combined <- arrangeGrob(betula_composition_gdd_phyla2, betula_composition_gdd_gen2,
ncol = 2, nrow = 1)
# Save the combined plot
ggsave("betula_gen_phy_combined.jpg", betula_gen_phy_combined, width = 7, height = 4.85) # Adjust width and height as needed
### Taxonomic Abundance for Populus tremuloides (PHYLUM)
# Assuming GDD_5C is a numeric variable in your sample data
subset_ps_populus <- subset_samples(ps_phen_asv_LMM, Species == "Populus_tremuloides")
ps_pop_phy <- tax_glom(subset_ps_populus, "Phylum")
ps0_pop_phy <- transform_sample_counts(ps_pop_phy, function(x) x/sum(x))
ps1_pop_phy <- merge_samples(ps0_pop_phy, "GDD_5C_bins")
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
ps2_pop_phy <- transform_sample_counts(ps1_pop_phy, function(x) x/sum(x))
# Manually restore GDD_5C_bins to sample_data
sample_data(ps2_pop_phy)$GDD_5C_bins <- factor(rownames(sample_data(ps2_pop_phy)),
levels = c("437", "605", "1087", "1606", "1992", "2140", "2219"))
# Create a bar plot
populus_composition_gdd_phyla2 <- plot_bar(ps2_pop_phy, x = "GDD_5C_bins", fill = "Phylum") +
labs(x = expression("Growing Degree Days (" * T[base] * " = 5" ~ degree * C *
")"), y = "Relative Abundance") + theme(axis.title.x = element_text(size = 8),
axis.title.y = element_text(size = 8), axis.text.x = element_text(size = 6),
axis.text.y = element_text(size = 6), legend.title = element_text(size = 8),
legend.text = element_text(size = 8), panel.border = element_rect(color = "black",
size = 1, fill = NA), axis.ticks = element_line(color = "black")) + guides(fill = guide_legend(keyheight = 0.75,
keywidth = 0.75, ncol = 1))
## Warning in psmelt(physeq): The sample variables:
## Species
## have been renamed to:
## sample_Species
## to avoid conflicts with taxonomic rank names.
# Print the bar plot
print(populus_composition_gdd_phyla2)
ggsave("populus_composition_gdd_phyla2.png", plot = populus_composition_gdd_phyla2,
width = 10, height = 6, units = "in", dpi = 300)
################################################################################ POPULUS
################################################################################ ORDERS
################################################################################ (ACROSS
################################################################################ GDDs)
# Assuming GDD_5C is a numeric variable in your sample data
subset_ps_populus <- subset_samples(ps_phen_asv_LMM, Species == "Populus_tremuloides")
ps_pop_ord <- tax_glom(subset_ps_populus, "Order")
ps0_pop_ord <- transform_sample_counts(ps_pop_ord, function(x) x/sum(x))
ps1_pop_ord <- merge_samples(ps0_pop_ord, "GDD_5C_bins")
ps2_pop_ord <- transform_sample_counts(ps1_pop_ord, function(x) x/sum(x))
# Create a bar plot
populus_composition_gdd_ord <- plot_bar(ps2_pop_ord, x = "GDD_5C_bins", fill = "Order") +
labs(title = "Taxonomic Abundance for Populus tremuloides", x = "Growing Degree Days (5C)",
y = "% Relative Abundance")
# Print the bar plot
print(populus_composition_gdd_ord)
################################################################################ POPULUS
################################################################################ FAMILIES
################################################################################ (ACROSS
################################################################################ GDDs)
# Assuming GDD_5C is a numeric variable in your sample data
subset_ps_populus <- subset_samples(ps_phen_asv_LMM, Species == "Populus_tremuloides")
ps_pop_fam <- tax_glom(subset_ps_populus, "Family")
ps0_pop_fam <- transform_sample_counts(ps_pop_fam, function(x) x/sum(x))
ps1_pop_fam <- merge_samples(ps0_pop_fam, "GDD_5C_bins")
ps2_pop_fam <- transform_sample_counts(ps1_pop_fam, function(x) x/sum(x))
# Create a bar plot
populus_composition_gdd_fam <- plot_bar(ps2_pop_fam, x = "GDD_5C_bins", fill = "Family") +
labs(title = "Taxonomic Abundance for Populus tremuloides", x = "Growing Degree Days (5C)",
y = "% Relative Abundance") + theme(legend.position = "bottom")
# Print the bar plot
print(populus_composition_gdd_fam)
ggsave("populus_comp_gdd_fam.png", plot = populus_composition_gdd_fam, width = 18,
height = 14, units = "in", dpi = 300)
################################################################################ POPULUS
################################################################################ GENERA
################################################################################ (ACROSS
################################################################################ GDDs)
library(phyloseq)
library(ggplot2)
library(dplyr)
# Assuming GDD_5C is a numeric variable in your sample data
subset_ps_populus <- subset_samples(ps_phen_asv_LMM, Species == "Populus_tremuloides")
# Aggregate at the Genus level
ps_pop_gen2 <- tax_glom(subset_ps_populus, "Genus")
# Transform to relative abundances
ps0_pop_gen2 <- transform_sample_counts(ps_pop_gen2, function(x) x/sum(x))
# Summarize the abundance of each genus across all samples
genus_abundance2 <- taxa_sums(ps0_pop_gen2)
genus_abundance_df2 <- data.frame(Genus = names(genus_abundance2), Abundance = genus_abundance2)
# Sort genera by abundance and select the top genera
top_n2 <- 20 # Change this to the number of top genera you want to plot
top_genera2 <- genus_abundance_df2 %>%
arrange(desc(Abundance)) %>%
head(top_n2) %>%
pull(Genus)
# Filter the phyloseq object to keep only the top genera
ps0_pop_gen2 <- prune_taxa(top_genera2, ps0_pop_gen2)
# Merge samples based on GDD_5C_bins
ps1_pop_gen2 <- merge_samples(ps0_pop_gen2, "GDD_5C_bins")
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
## Warning in asMethod(object): NAs introduced by coercion
# Manually restore GDD_5C_bins to sample_data
sample_data(ps1_pop_gen2)$GDD_5C_bins <- factor(rownames(sample_data(ps1_pop_gen2)),
levels = c("437", "605", "1087", "1606", "1992", "2140", "2219"))
# Transform to relative abundances again after merging
ps2_pop_gen2 <- transform_sample_counts(ps1_pop_gen2, function(x) x/sum(x))
library(ggplot2)
library(patchwork)
# Get GDD bin levels
gdd_levels <- levels(sample_data(ps2_pop_gen2)$GDD_5C_bins)
x_start <- 0.5
x_end <- length(gdd_levels) + 0.5
# Title bar plot with top and side borders only
populus_title_bar <- ggplot() +
# Background grey rectangle
geom_rect(aes(xmin = x_start, xmax = x_end, ymin = 0.5, ymax = 0.75),
fill = "grey90", color = NA) +
# Top border
geom_segment(aes(x = x_start, xend = x_end, y = 0.75, yend = 0.75), color = "black", linewidth = 0.6) +
# Left border
geom_segment(aes(x = x_start, xend = x_start, y = 0.5, yend = 0.75), color = "black", linewidth = 0.6) +
# Right border
geom_segment(aes(x = x_end, xend = x_end, y = 0.5, yend = 0.75), color = "black", linewidth = 0.6) +
# Centered title text
annotate("text", x = median(seq_along(gdd_levels)), y = 0.61,
label = expression("bold('Trembling Aspen')"), parse = TRUE, size = 3) +
scale_x_continuous(expand = c(0, 0), limits = c(x_start, x_end)) +
scale_y_continuous(limits = c(0.5, 1.2), expand = c(0, 0)) +
coord_cartesian(clip = "off") +
theme_void() +
theme(
plot.margin = ggplot2::unit(c(0, 0.1, 0, 0.1), "pt") # no bottom margin so it fuses
)
# Actual bar plot
populus_composition_gdd_gen3 <- plot_bar(ps2_pop_gen2, x = "GDD_5C_bins", fill = "Genus") +
labs(x = expression("Growing Degree Days (" * T[base] * " = 5"~degree*C * ")"), y = "Relative Abundance") +
scale_fill_manual(
values = genus_colors_relabund,
labels = function(x) {
str_replace(x, "Methylobacterium-Methylorubrum", "Methylobacterium-\nMethylorubrum")
}
) +
scale_y_continuous(limits = c(0, 1), expand = c(0, 0)) +
guides(fill = guide_legend(keyheight = 0.5, keywidth = 0.5)) +
theme(
axis.title.x = element_text(size = 6),
axis.title.y = element_text(size = 6),
axis.text.x = element_text(size = 6, angle = 0, hjust = 0.5),
axis.text.y = element_text(size = 6),
legend.title = element_text(size = 6),
legend.text = element_text(size = 5),
legend.box.margin = margin(0, 0, 0, -10, unit = "pt"),
panel.border = element_rect(color = "black", size = 1, fill = NA),
axis.ticks = element_line(color = "black"),
plot.margin = unit(c(0, 0, 0, 0), "pt"),
panel.grid = element_blank(),
panel.background = element_rect(fill = "white", color = NA)
)
## Warning in psmelt(physeq): The sample variables:
## Species
## have been renamed to:
## sample_Species
## to avoid conflicts with taxonomic rank names.
# Combine the title bar and the actual plot
populus_gen_composition_final <- populus_title_bar / populus_composition_gdd_gen3 +
plot_layout(heights = c(0.12, 1)) & # apply theme to both
theme(
plot.margin = ggplot2::unit(c(0, 0, 0, 0), "pt")
)
populus_gen_composition_final
## Warning in is.na(x): is.na() applied to non-(list or vector) of type
## 'expression'
# Subset the phyloseq object to only include samples from GDD_5C_bins 1606
ps_gdd_437_pop <- subset_samples(ps0_pop_gen2, GDD_5C_bins == "437")
ps_gdd_605_pop <- subset_samples(ps0_pop_gen2, GDD_5C_bins == "605")
ps_gdd_1087_pop <- subset_samples(ps0_pop_gen2, GDD_5C_bins == "1087")
ps_gdd_1606_pop <- subset_samples(ps0_pop_gen2, GDD_5C_bins == "1606")
ps_gdd_1992_pop <- subset_samples(ps0_pop_gen2, GDD_5C_bins == "1992")
ps_gdd_2140_pop <- subset_samples(ps0_pop_gen2, GDD_5C_bins == "2140")
ps_gdd_2219_pop <- subset_samples(ps0_pop_gen2, GDD_5C_bins == "2219")
# Transform to relative abundances
ps_gdd_437_relabund_pop <- transform_sample_counts(ps_gdd_437_pop, function(x) x/sum(x))
ps_gdd_605_relabund_pop <- transform_sample_counts(ps_gdd_605_pop, function(x) x/sum(x))
ps_gdd_1087_relabund_pop <- transform_sample_counts(ps_gdd_1087_pop, function(x) x/sum(x))
ps_gdd_1606_relabund_pop <- transform_sample_counts(ps_gdd_1606_pop, function(x) x/sum(x))
ps_gdd_1992_relabund_pop <- transform_sample_counts(ps_gdd_1992_pop, function(x) x/sum(x))
ps_gdd_2140_relabund_pop <- transform_sample_counts(ps_gdd_2140_pop, function(x) x/sum(x))
ps_gdd_2219_relabund_pop <- transform_sample_counts(ps_gdd_2219_pop, function(x) x/sum(x))
# Create a bar plot for the top genera at GDD 437, with Plant_ID on the x-axis
gdd_437_composition_plot_pop <- plot_bar(ps_gdd_437_relabund_pop, x = "Plant_ID",
fill = "Genus") + labs(x = "Plant ID", y = "Relative Abundance", title = "Relative Abundance of Top Genera at GDD 437") +
theme(axis.title.x = element_text(size = 8), axis.title.y = element_text(size = 8),
axis.text.x = element_text(size = 6, angle = 45, hjust = 1), axis.text.y = element_text(size = 6),
legend.title = element_text(size = 8), legend.text = element_text(size = 8),
panel.border = element_rect(color = "black", size = 1, fill = NA), axis.ticks = element_line(color = "black")) +
scale_fill_manual(values = genus_colors_relabund) + guides(fill = guide_legend(keyheight = 0.75,
keywidth = 0.75))
## Warning in psmelt(physeq): The sample variables:
## Species
## have been renamed to:
## sample_Species
## to avoid conflicts with taxonomic rank names.
# Print the bar plot
print(gdd_437_composition_plot_pop)
###############################################################################
# Create a bar plot for the top genera at GDD 605, with Plant_ID on the x-axis
gdd_605_composition_plot_pop <- plot_bar(ps_gdd_605_relabund_pop, x = "Plant_ID",
fill = "Genus") + labs(x = "Plant ID", y = "Relative Abundance", title = "Relative Abundance of Top Genera at GDD 605") +
theme(axis.title.x = element_text(size = 8), axis.title.y = element_text(size = 8),
axis.text.x = element_text(size = 6, angle = 45, hjust = 1), axis.text.y = element_text(size = 6),
legend.title = element_text(size = 8), legend.text = element_text(size = 8),
panel.border = element_rect(color = "black", size = 1, fill = NA), axis.ticks = element_line(color = "black")) +
scale_fill_manual(values = genus_colors_relabund) + guides(fill = guide_legend(keyheight = 0.75,
keywidth = 0.75))
## Warning in psmelt(physeq): The sample variables:
## Species
## have been renamed to:
## sample_Species
## to avoid conflicts with taxonomic rank names.
# Print the bar plot
print(gdd_605_composition_plot_pop)
###############################################################################
# Create a bar plot for the top genera at GDD 1087, with Plant_ID on the x-axis
gdd_1087_composition_plot_pop <- plot_bar(ps_gdd_1087_relabund_pop, x = "sample_id",
fill = "Genus") + labs(x = "Sample ID", y = "Relative Abundance", title = "Relative Abundance of Top Genera at GDD 1087") +
theme(axis.title.x = element_text(size = 8), axis.title.y = element_text(size = 8),
axis.text.x = element_text(size = 6, angle = 45, hjust = 1), axis.text.y = element_text(size = 6),
legend.title = element_text(size = 8), legend.text = element_text(size = 8),
panel.border = element_rect(color = "black", size = 1, fill = NA), axis.ticks = element_line(color = "black")) +
scale_fill_manual(values = genus_colors_relabund) + guides(fill = guide_legend(keyheight = 0.75,
keywidth = 0.75))
## Warning in psmelt(physeq): The sample variables:
## Species
## have been renamed to:
## sample_Species
## to avoid conflicts with taxonomic rank names.
# Print the bar plot
print(gdd_1087_composition_plot_pop)
###############################################################################
# Create a bar plot for the top genera at GDD 1606, with Plant_ID on the x-axis
gdd_1606_composition_plot_pop <- plot_bar(ps_gdd_1606_relabund_pop, x = "Plant_ID",
fill = "Genus") + labs(x = "Plant ID", y = "Relative Abundance", title = "Relative Abundance of Top Genera at GDD 1606") +
theme(axis.title.x = element_text(size = 8), axis.title.y = element_text(size = 8),
axis.text.x = element_text(size = 6, angle = 45, hjust = 1), axis.text.y = element_text(size = 6),
legend.title = element_text(size = 8), legend.text = element_text(size = 8),
panel.border = element_rect(color = "black", size = 1, fill = NA), axis.ticks = element_line(color = "black")) +
scale_fill_manual(values = genus_colors_relabund) + guides(fill = guide_legend(keyheight = 0.75,
keywidth = 0.75))
## Warning in psmelt(physeq): The sample variables:
## Species
## have been renamed to:
## sample_Species
## to avoid conflicts with taxonomic rank names.
# Print the bar plot
print(gdd_1606_composition_plot_pop)
################################################################################
# Create a bar plot for the top genera at GDD 1992, with Plant_ID on the x-axis
gdd_1992_composition_plot_pop <- plot_bar(ps_gdd_1992_relabund_pop, x = "Plant_ID",
fill = "Genus") + labs(x = "Plant ID", y = "Relative Abundance", title = "Relative Abundance of Top Genera at GDD 1992") +
theme(axis.title.x = element_text(size = 8), axis.title.y = element_text(size = 8),
axis.text.x = element_text(size = 6, angle = 45, hjust = 1), axis.text.y = element_text(size = 6),
legend.title = element_text(size = 8), legend.text = element_text(size = 8),
panel.border = element_rect(color = "black", size = 1, fill = NA), axis.ticks = element_line(color = "black")) +
scale_fill_manual(values = genus_colors_relabund) + guides(fill = guide_legend(keyheight = 0.75,
keywidth = 0.75))
## Warning in psmelt(physeq): The sample variables:
## Species
## have been renamed to:
## sample_Species
## to avoid conflicts with taxonomic rank names.
# Print the bar plot
print(gdd_1992_composition_plot_pop)
################################################################################
# Create a bar plot for the top genera at GDD 2140, with Plant_ID on the x-axis
gdd_2140_composition_plot_pop <- plot_bar(ps_gdd_2140_relabund_pop, x = "Plant_ID",
fill = "Genus") + labs(x = "Plant ID", y = "Relative Abundance", title = "Relative Abundance of Top Genera at GDD 2140") +
theme(axis.title.x = element_text(size = 8), axis.title.y = element_text(size = 8),
axis.text.x = element_text(size = 6, angle = 45, hjust = 1), axis.text.y = element_text(size = 6),
legend.title = element_text(size = 8), legend.text = element_text(size = 8),
panel.border = element_rect(color = "black", size = 1, fill = NA), axis.ticks = element_line(color = "black")) +
scale_fill_manual(values = genus_colors_relabund) + guides(fill = guide_legend(keyheight = 0.75,
keywidth = 0.75))
## Warning in psmelt(physeq): The sample variables:
## Species
## have been renamed to:
## sample_Species
## to avoid conflicts with taxonomic rank names.
# Print the bar plot
print(gdd_2140_composition_plot_pop)
################################################################################
# Create a bar plot for the top genera at GDD 2219, with Plant_ID on the x-axis
gdd_2219_composition_plot_pop <- plot_bar(ps_gdd_2219_relabund_pop, x = "Plant_ID",
fill = "Genus") + labs(x = "Plant ID", y = "Relative Abundance", title = "Relative Abundance of Top Genera at GDD 2219") +
theme(axis.title.x = element_text(size = 8), axis.title.y = element_text(size = 8),
axis.text.x = element_text(size = 6, angle = 45, hjust = 1), axis.text.y = element_text(size = 6),
legend.title = element_text(size = 8), legend.text = element_text(size = 8),
panel.border = element_rect(color = "black", size = 1, fill = NA), axis.ticks = element_line(color = "black")) +
scale_fill_manual(values = genus_colors_relabund) + guides(fill = guide_legend(keyheight = 0.75,
keywidth = 0.75))
## Warning in psmelt(physeq): The sample variables:
## Species
## have been renamed to:
## sample_Species
## to avoid conflicts with taxonomic rank names.
# Print the bar plot
print(gdd_2219_composition_plot_pop)
ggsave("populus_gen_composition_final.png", plot = populus_gen_composition_final,
width = 12, height = 8, units = "in", dpi = 300)
# Arrange the plots in a grid
populus_gen_phy_combined <- arrangeGrob(populus_composition_gdd_phyla2, populus_composition_gdd_gen2,
ncol = 2, nrow = 1)
# Save the combined plot
ggsave("populus_gen_phy_combined.jpg", populus_gen_phy_combined, width = 7, height = 4.85) # Adjust width and height as needed
# Arrange the plots in a grid
relabund_phyla_combined <- arrangeGrob(betula_composition_gdd_phyla2, populus_composition_gdd_phyla2,
ncol = 1, nrow = 2)
# Save the combined plot
ggsave("relabund_phyla_combined.png", relabund_phyla_combined, width = 7, height = 7,
dpi = 300, device = "png") # Adjust width and height as needed
# Arrange the plots in a grid
relabund_genus_combined <- arrangeGrob(betula_gen_composition_final, populus_gen_composition_final,
ncol = 1, nrow = 2)
# Save the combined plot
ggsave("relabund_genus_combined.jpg", relabund_genus_combined, width = 7, height = 7) # Adjust width and height as needed
if (!require(“BiocManager”, quietly = TRUE)) install.packages(“BiocManager”)
BiocManager::install(“DESeq2”)
library(DESeq2)
library(phyloseq)
#-------------------------------------------------------
## FOR `asv_scaled_noPlants_Phenology_stats_LMM` (i.e.,
## `asv_scaled_noPlants_Phen_filt_LMM`)
#-------------------------------------------------------
# Extract the count data (otu_table) and sample metadata (sample_data) from the
# phyloseq object.
# Extract count data
otu_counts_LMM <- otu_table(ps_phen_asv_LMM)
# Extract sample metadata
sample_metadata_LMM <- sample_data(ps_phen_asv_LMM)
# DESeq2 requires count data to be in a specific format. Convert the count data
# into a matrix, and create a DESeq2 DDS object.
# Convert count data to matrix
otu_counts_matrix_LMM <- as.matrix(otu_counts_LMM)
# check that samples in metadata match those in the community data file
(row.names(asv_scaled_noPlants_Phenology_stats_LMM) == row.names(otu_counts_LMM))
## [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
## [16] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
## [31] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
## [46] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
## [61] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
# Step 1: Transpose the otu_counts_matrix
transposed_otu_counts_matrix_LMM <- t(otu_counts_matrix_LMM)
# Also
ncol(transposed_otu_counts_matrix_LMM) == nrow(asv_scaled_noPlants_Phenology_stats_LMM)
## [1] TRUE
# Step 2: Add a pseudocount: You can add a small pseudocount to all counts to
# avoid zero counts before creating the DESeq2 object
transposed_otu_counts_matrix_LMM <- transposed_otu_counts_matrix_LMM + 1
# Having issues with knitting, so use the `globalenv()` Function:** In the R
# code chunk where you define `transposed_otu_counts_matrix`, you can
# explicitly set the environment to the global environment using `assign()` and
# `globalenv()`:
assign("transposed_otu_counts_matrix_LMM", transposed_otu_counts_matrix_LMM, envir = globalenv())
# Step 3: Create a new phyloseq object using the transposed count matrix
ps_phen_asv_transposed_LMM <- phyloseq(otu_table(transposed_otu_counts_matrix_LMM,
taxa_are_rows = TRUE), sample_data(sample_metadata_LMM), tax_table(taxa_rdp))
ps_betula <- subset_samples(ps_phen_asv_transposed_LMM, Species == "Betula_populifolia")
ps_populus <- subset_samples(ps_phen_asv_transposed_LMM, Species == "Populus_tremuloides")
# Step 4: Convert the phyloseq object to a DESeqDataSet
dds_LMM <- phyloseq_to_deseq2(ps_phen_asv_transposed_LMM, ~Species + GDD_5C + Species:GDD_5C)
## converting counts to integer mode
## the design formula contains one or more numeric variables with integer values,
## specifying a model with increasing fold change for higher values.
## did you mean for this to be a factor? if so, first convert
## this variable to a factor using the factor() function
## the design formula contains one or more numeric variables that have mean or
## standard deviation larger than 5 (an arbitrary threshold to trigger this message).
## Including numeric variables with large mean can induce collinearity with the intercept.
## Users should center and scale numeric variables in the design to improve GLM convergence.
dds_gdd <- phyloseq_to_deseq2(ps_phen_asv_transposed_LMM, ~Species)
## converting counts to integer mode
dds_betula <- phyloseq_to_deseq2(ps_betula, ~GDD_5C_bins)
## converting counts to integer mode
dds_populus <- phyloseq_to_deseq2(ps_populus, ~GDD_5C_bins)
## converting counts to integer mode
sample_data(ps_betula)$GDD_5C_scaled <- scale(sample_data(ps_betula)$GDD_5C)
sample_data(ps_populus)$GDD_5C_scaled <- scale(sample_data(ps_populus)$GDD_5C)
dds_betula_cont <- phyloseq_to_deseq2(ps_betula, ~GDD_5C_scaled)
## converting counts to integer mode
dds_populus_cont <- phyloseq_to_deseq2(ps_populus, ~GDD_5C_scaled)
## converting counts to integer mode
# Now, subset each `GDD_5C`:
dds_437 <- dds_gdd[, dds_gdd$GDD_5C %in% c(437)]
dds_605 <- dds_gdd[, dds_gdd$GDD_5C %in% c(605)]
dds_1087 <- dds_gdd[, dds_gdd$GDD_5C %in% c(1087)]
dds_1606 <- dds_gdd[, dds_gdd$GDD_5C %in% c(1606)]
dds_1992 <- dds_gdd[, dds_gdd$GDD_5C %in% c(1992)]
dds_2140 <- dds_gdd[, dds_gdd$GDD_5C %in% c(2140)]
dds_2219 <- dds_gdd[, dds_gdd$GDD_5C %in% c(2219)]
# Now, you can use DESeq2 to perform differential abundance analysis. This will
# help identify ASVs and taxa associated with tree species and
# Growing-Degree-Days-5C.
# Perform DESeq2 analysis
dds_LMM <- DESeq(dds_LMM)
## estimating size factors
## estimating dispersions
## gene-wise dispersion estimates
## mean-dispersion relationship
## -- note: fitType='parametric', but the dispersion trend was not well captured by the
## function: y = a/x + b, and a local regression fit was automatically substituted.
## specify fitType='local' or 'mean' to avoid this message next time.
## final dispersion estimates
## fitting model and testing
dds_437 <- DESeq(dds_437)
## estimating size factors
## estimating dispersions
## gene-wise dispersion estimates
## mean-dispersion relationship
## -- note: fitType='parametric', but the dispersion trend was not well captured by the
## function: y = a/x + b, and a local regression fit was automatically substituted.
## specify fitType='local' or 'mean' to avoid this message next time.
## final dispersion estimates
## fitting model and testing
dds_605 <- DESeq(dds_605)
## estimating size factors
## estimating dispersions
## gene-wise dispersion estimates
## mean-dispersion relationship
## -- note: fitType='parametric', but the dispersion trend was not well captured by the
## function: y = a/x + b, and a local regression fit was automatically substituted.
## specify fitType='local' or 'mean' to avoid this message next time.
## final dispersion estimates
## fitting model and testing
dds_1087 <- DESeq(dds_1087)
## estimating size factors
## estimating dispersions
## gene-wise dispersion estimates
## mean-dispersion relationship
## -- note: fitType='parametric', but the dispersion trend was not well captured by the
## function: y = a/x + b, and a local regression fit was automatically substituted.
## specify fitType='local' or 'mean' to avoid this message next time.
## final dispersion estimates
## fitting model and testing
dds_1606 <- DESeq(dds_1606)
## estimating size factors
## estimating dispersions
## gene-wise dispersion estimates
## mean-dispersion relationship
## -- note: fitType='parametric', but the dispersion trend was not well captured by the
## function: y = a/x + b, and a local regression fit was automatically substituted.
## specify fitType='local' or 'mean' to avoid this message next time.
## final dispersion estimates
## fitting model and testing
dds_1992 <- DESeq(dds_1992)
## estimating size factors
## estimating dispersions
## gene-wise dispersion estimates
## mean-dispersion relationship
## -- note: fitType='parametric', but the dispersion trend was not well captured by the
## function: y = a/x + b, and a local regression fit was automatically substituted.
## specify fitType='local' or 'mean' to avoid this message next time.
## final dispersion estimates
## fitting model and testing
dds_2140 <- DESeq(dds_2140)
## estimating size factors
## estimating dispersions
## gene-wise dispersion estimates
## mean-dispersion relationship
## -- note: fitType='parametric', but the dispersion trend was not well captured by the
## function: y = a/x + b, and a local regression fit was automatically substituted.
## specify fitType='local' or 'mean' to avoid this message next time.
## final dispersion estimates
## fitting model and testing
dds_2219 <- DESeq(dds_2219)
## estimating size factors
## estimating dispersions
## gene-wise dispersion estimates
## mean-dispersion relationship
## -- note: fitType='parametric', but the dispersion trend was not well captured by the
## function: y = a/x + b, and a local regression fit was automatically substituted.
## specify fitType='local' or 'mean' to avoid this message next time.
## final dispersion estimates
## fitting model and testing
# Intraspecific DESeq2:
dds_betula <- DESeq(dds_betula)
## estimating size factors
## estimating dispersions
## gene-wise dispersion estimates
## mean-dispersion relationship
## -- note: fitType='parametric', but the dispersion trend was not well captured by the
## function: y = a/x + b, and a local regression fit was automatically substituted.
## specify fitType='local' or 'mean' to avoid this message next time.
## final dispersion estimates
## fitting model and testing
dds_populus <- DESeq(dds_populus)
## estimating size factors
## estimating dispersions
## gene-wise dispersion estimates
## mean-dispersion relationship
## -- note: fitType='parametric', but the dispersion trend was not well captured by the
## function: y = a/x + b, and a local regression fit was automatically substituted.
## specify fitType='local' or 'mean' to avoid this message next time.
## final dispersion estimates
## fitting model and testing
dds_betula_cont <- DESeq(dds_betula_cont)
## estimating size factors
## estimating dispersions
## gene-wise dispersion estimates
## mean-dispersion relationship
## -- note: fitType='parametric', but the dispersion trend was not well captured by the
## function: y = a/x + b, and a local regression fit was automatically substituted.
## specify fitType='local' or 'mean' to avoid this message next time.
## final dispersion estimates
## fitting model and testing
dds_populus_cont <- DESeq(dds_populus_cont)
## estimating size factors
## estimating dispersions
## gene-wise dispersion estimates
## mean-dispersion relationship
## -- note: fitType='parametric', but the dispersion trend was not well captured by the
## function: y = a/x + b, and a local regression fit was automatically substituted.
## specify fitType='local' or 'mean' to avoid this message next time.
## final dispersion estimates
## fitting model and testing
#-------------------------------------------------------
## FOR `asv_scaled_noPlants_Phenology_stats_LMM` (i.e.,
## `asv_scaled_noPlants_Phen_filt_LMM`)
#-------------------------------------------------------
# Get differential abundance results for tree species
results_species_diff_abund_LMM <- results(dds_LMM, contrast = c("Species", "Betula_populifolia",
"Populus_tremuloides"))
results_interaction_diff_abund_LMM <- results(dds_LMM, name = "SpeciesPopulus_tremuloides.GDD_5C")
results_gdd_trend_betula <- results(dds_betula_cont, name = "GDD_5C_scaled")
results_gdd_trend_populus <- results(dds_populus_cont, name = "GDD_5C_scaled")
# significant_asvs_species_LMM <- subset(results_species_diff_abund_LMM, padj <
# 0.1)
significant_asvs_species_LMM <- subset(results_species_diff_abund_LMM)
significant_asvs_interaction_LMM <- subset(results_interaction_diff_abund_LMM)
significant_asvs_betula_contin_trend <- subset(results_gdd_trend_betula)
significant_asvs_populus_contin_trend <- subset(results_gdd_trend_populus)
head(significant_asvs_species_LMM)
## log2 fold change (MLE): Species Betula_populifolia vs Populus_tremuloides
## Wald test p-value: Species Betula_populifolia vs Populus_tremuloides
## DataFrame with 6 rows and 6 columns
## baseMean log2FoldChange lfcSE stat pvalue padj
## <numeric> <numeric> <numeric> <numeric> <numeric> <numeric>
## ASV7 257.83243 0.39360659 1.211366 0.32492801 7.45236e-01 8.70875e-01
## ASV8 171.26875 -3.70781174 1.085313 -3.41635114 6.34664e-04 2.54659e-02
## ASV9 140.79339 1.14526762 1.242586 0.92168109 3.56695e-01 6.58041e-01
## ASV10 137.11819 6.27075947 0.974829 6.43267345 1.25379e-10 4.02466e-08
## ASV12 68.66647 -0.54258672 1.180701 -0.45954630 6.45842e-01 8.22680e-01
## ASV13 1.03461 0.00126776 0.803494 0.00157781 9.98741e-01 NA
head(significant_asvs_interaction_LMM)
## log2 fold change (MLE): SpeciesPopulus tremuloides.GDD 5C
## Wald test p-value: SpeciesPopulus tremuloides.GDD 5C
## DataFrame with 6 rows and 6 columns
## baseMean log2FoldChange lfcSE stat pvalue padj
## <numeric> <numeric> <numeric> <numeric> <numeric> <numeric>
## ASV7 257.83243 -4.24238e-03 0.000775556 -5.47011006 4.49756e-08 3.26823e-06
## ASV8 171.26875 -5.84474e-03 0.000674916 -8.65994751 4.71982e-18 1.02892e-15
## ASV9 140.79339 -2.58758e-03 0.000778785 -3.32258710 8.91868e-04 1.38877e-02
## ASV10 137.11819 -1.08912e-03 0.000625235 -1.74194285 8.15184e-02 2.24950e-01
## ASV12 68.66647 1.18801e-03 0.000743032 1.59886882 1.09850e-01 2.60296e-01
## ASV13 1.03461 7.61080e-07 0.000505900 0.00150441 9.98800e-01 NA
head(significant_asvs_betula_contin_trend)
## log2 fold change (MLE): GDD 5C scaled
## Wald test p-value: GDD 5C scaled
## DataFrame with 6 rows and 6 columns
## baseMean log2FoldChange lfcSE stat pvalue padj
## <numeric> <numeric> <numeric> <numeric> <numeric> <numeric>
## ASV7 502.7143 2.12421e+00 0.415042 5.11806e+00 3.08696e-07 9.26089e-06
## ASV8 333.2000 3.83859e+00 0.354450 1.08297e+01 2.48939e-27 6.72134e-25
## ASV9 271.9714 2.03967e+00 0.413342 4.93459e+00 8.03182e-07 1.97145e-05
## ASV10 267.7714 5.05047e-01 0.311861 1.61946e+00 1.05348e-01 1.85737e-01
## ASV12 22.1143 -7.99682e-03 0.299532 -2.66977e-02 9.78701e-01 9.78701e-01
## ASV13 1.0000 1.66599e-27 0.257801 6.46232e-27 1.00000e+00 NA
head(significant_asvs_populus_contin_trend)
## log2 fold change (MLE): GDD 5C scaled
## Wald test p-value: GDD 5C scaled
## DataFrame with 6 rows and 6 columns
## baseMean log2FoldChange lfcSE stat pvalue padj
## <numeric> <numeric> <numeric> <numeric> <numeric> <numeric>
## ASV7 3.02256 -0.805976417 0.324142 -2.486488615 NA NA
## ASV8 2.76172 -0.220395331 0.291686 -0.755591088 0.449894 0.588462
## ASV9 4.30244 0.246337151 0.333524 0.738589936 0.460156 0.596059
## ASV10 1.19329 -0.257292520 0.237150 -1.084936463 0.277950 NA
## ASV12 114.65234 0.810487111 0.407944 1.986759926 NA NA
## ASV13 1.04731 -0.000229578 0.257830 -0.000890425 0.999290 NA
####Visualizing significant ASVs’ abundance patterns: 1st, those that differ between hosts overall, then 2nd, those whose GDD response differs by host - to see if the expected separations/trends show up across samples. ################################################################################
#-------------------------------------------------------
## FOR `asv_scaled_noPlants_Phenology_stats_LMM` (i.e.,
## `asv_scaled_noPlants_Phen_filt_LMM`)
#-------------------------------------------------------
# ASV Heatmap:
# Assuming 'dds' is your DESeq2 object and 'top_asvs' is the data frame
# containing top ASVs
top_asv_names_LMM <- rownames(significant_asvs_species_LMM)
top_asv_counts_LMM <- counts(dds_LMM)[top_asv_names_LMM, ]
top_asv_names_interaction <- rownames(significant_asvs_interaction_LMM)
top_asv_counts_interaction <- counts(dds_LMM)[top_asv_names_interaction, ]
# Create the heatmap
heatmap(as.matrix(top_asv_counts_LMM), scale = "row", Rowv = FALSE, Colv = FALSE,
col = viridis::viridis(100))
heatmap(as.matrix(top_asv_counts_interaction), scale = "row", Rowv = FALSE, Colv = FALSE,
col = viridis::viridis(100))
####Visualize within-species (Betula) DA patterns across GDD, showing how significant ASVs change with GDD accumulation. ################################################################################
#-------------------------------------------------------
## INTRAspecific variation
#-------------------------------------------------------
# ASV Heatmap:
# Betula:
top_asv_names_bet_cont_trend <- rownames(significant_asvs_betula_contin_trend)
top_asv_counts_bet_cont_trend <- counts(dds_betula_cont)[top_asv_names_bet_cont_trend,
]
heatmap(as.matrix(top_asv_counts_bet_cont_trend), scale = "row", Rowv = FALSE, Colv = FALSE,
col = viridis::viridis(100))
####Visualize within-species (Populus) DA patterns across GDD, showing how significant ASVs change with GDD accumulation. ################################################################################
# Populus:
top_asv_names_pop_cont_trend <- rownames(significant_asvs_populus_contin_trend)
top_asv_counts_pop_cont_trend <- counts(dds_populus_cont)[top_asv_names_pop_cont_trend,
]
heatmap(as.matrix(top_asv_counts_pop_cont_trend), scale = "row", Rowv = FALSE, Colv = FALSE,
col = viridis::viridis(100))
# Save the heatmap as a PDF file
pdf("diffabund_heatmap_output.pdf")
# Your heatmap code again (to generate and save it in the PDF)
heatmap(as.matrix(top_asv_counts_LMM), scale = "row", Rowv = FALSE, Colv = FALSE,
col = viridis::viridis(100))
# Close the PDF file
dev.off()
####Creates & print summary tables of significant ASVs for the species and interaction models, listing key DESeq2 statistics with added genus-level taxonomy for interpretation. ################################################################################
#-------------------------------------------------------
## FOR `asv_scaled_noPlants_Phenology_stats_LMM` (i.e.,
## `asv_scaled_noPlants_Phen_filt_LMM`)
#-------------------------------------------------------
#-------------------------------------------------------
# Top ASVs Table for Species:
#-------------------------------------------------------
# Select the columns you want in the table
top_asv_table_spp_LMM <- significant_asvs_species_LMM[, c("baseMean", "log2FoldChange",
"lfcSE", "stat", "pvalue", "padj")]
top_asv_table_spp_interaction <- significant_asvs_interaction_LMM[, c("baseMean",
"log2FoldChange", "lfcSE", "stat", "pvalue", "padj")]
# Optionally, you can add the taxonomic information if available
top_asv_table_spp_LMM$Genus <- taxa_rdp[rownames(top_asv_table_spp_LMM), "Genus"]
top_asv_table_spp_interaction$Genus <- taxa_rdp[rownames(top_asv_table_spp_interaction),
"Genus"]
# Print the table
print(top_asv_table_spp_LMM)
## log2 fold change (MLE): Species Betula_populifolia vs Populus_tremuloides
## Wald test p-value: Species Betula_populifolia vs Populus_tremuloides
## DataFrame with 1732 rows and 7 columns
## baseMean log2FoldChange lfcSE stat pvalue padj
## <numeric> <numeric> <numeric> <numeric> <numeric> <numeric>
## ASV7 257.8324 0.393607 1.211366 0.324928 7.45236e-01 8.70875e-01
## ASV8 171.2688 -3.707812 1.085313 -3.416351 6.34664e-04 2.54659e-02
## ASV9 140.7934 1.145268 1.242586 0.921681 3.56695e-01 6.58041e-01
## ASV10 137.1182 6.270759 0.974829 6.432673 1.25379e-10 4.02466e-08
## ASV12 68.6665 -0.542587 1.180701 -0.459546 6.45842e-01 8.22680e-01
## ... ... ... ... ... ... ...
## ASV1786 1.06375 -0.2693116 0.782736 -0.3440644 0.730798 NA
## ASV1787 1.06375 -0.0539938 0.802423 -0.0672885 0.946352 NA
## ASV1788 1.06375 -0.0539938 0.802423 -0.0672885 0.946352 NA
## ASV1789 1.06375 -0.0539938 0.802423 -0.0672885 0.946352 NA
## ASV1790 1.06375 0.0958526 0.804846 0.1190942 0.905201 NA
## Genus
## <character>
## ASV7 Endobacter
## ASV8 Endobacter
## ASV9 1174-901-12
## ASV10 NA
## ASV12 Staphylococcus
## ... ...
## ASV1786 NA
## ASV1787 Conexibacter
## ASV1788 Methylobacterium-Met..
## ASV1789 NA
## ASV1790 NA
print(top_asv_table_spp_interaction)
## log2 fold change (MLE): SpeciesPopulus tremuloides.GDD 5C
## Wald test p-value: SpeciesPopulus tremuloides.GDD 5C
## DataFrame with 1732 rows and 7 columns
## baseMean log2FoldChange lfcSE stat pvalue padj
## <numeric> <numeric> <numeric> <numeric> <numeric> <numeric>
## ASV7 257.8324 -0.00424238 0.000775556 -5.47011 4.49756e-08 3.26823e-06
## ASV8 171.2688 -0.00584474 0.000674916 -8.65995 4.71982e-18 1.02892e-15
## ASV9 140.7934 -0.00258758 0.000778785 -3.32259 8.91868e-04 1.38877e-02
## ASV10 137.1182 -0.00108912 0.000625235 -1.74194 8.15184e-02 2.24950e-01
## ASV12 68.6665 0.00118801 0.000743032 1.59887 1.09850e-01 2.60296e-01
## ... ... ... ... ... ... ...
## ASV1786 1.06375 -1.35883e-04 0.000498297 -0.272694 0.785088 NA
## ASV1787 1.06375 -9.22688e-05 0.000501397 -0.184023 0.853995 NA
## ASV1788 1.06375 -9.22688e-05 0.000501397 -0.184023 0.853995 NA
## ASV1789 1.06375 -9.22688e-05 0.000501397 -0.184023 0.853995 NA
## ASV1790 1.06375 1.19808e-04 0.000501884 0.238717 0.811325 NA
## Genus
## <character>
## ASV7 Endobacter
## ASV8 Endobacter
## ASV9 1174-901-12
## ASV10 NA
## ASV12 Staphylococcus
## ... ...
## ASV1786 NA
## ASV1787 Conexibacter
## ASV1788 Methylobacterium-Met..
## ASV1789 NA
## ASV1790 NA
head(top_asv_table_spp_LMM)
## log2 fold change (MLE): Species Betula_populifolia vs Populus_tremuloides
## Wald test p-value: Species Betula_populifolia vs Populus_tremuloides
## DataFrame with 6 rows and 7 columns
## baseMean log2FoldChange lfcSE stat pvalue padj
## <numeric> <numeric> <numeric> <numeric> <numeric> <numeric>
## ASV7 257.83243 0.39360659 1.211366 0.32492801 7.45236e-01 8.70875e-01
## ASV8 171.26875 -3.70781174 1.085313 -3.41635114 6.34664e-04 2.54659e-02
## ASV9 140.79339 1.14526762 1.242586 0.92168109 3.56695e-01 6.58041e-01
## ASV10 137.11819 6.27075947 0.974829 6.43267345 1.25379e-10 4.02466e-08
## ASV12 68.66647 -0.54258672 1.180701 -0.45954630 6.45842e-01 8.22680e-01
## ASV13 1.03461 0.00126776 0.803494 0.00157781 9.98741e-01 NA
## Genus
## <character>
## ASV7 Endobacter
## ASV8 Endobacter
## ASV9 1174-901-12
## ASV10 NA
## ASV12 Staphylococcus
## ASV13 Limosilactobacillus
head(top_asv_table_spp_interaction)
## log2 fold change (MLE): SpeciesPopulus tremuloides.GDD 5C
## Wald test p-value: SpeciesPopulus tremuloides.GDD 5C
## DataFrame with 6 rows and 7 columns
## baseMean log2FoldChange lfcSE stat pvalue padj
## <numeric> <numeric> <numeric> <numeric> <numeric> <numeric>
## ASV7 257.83243 -4.24238e-03 0.000775556 -5.47011006 4.49756e-08 3.26823e-06
## ASV8 171.26875 -5.84474e-03 0.000674916 -8.65994751 4.71982e-18 1.02892e-15
## ASV9 140.79339 -2.58758e-03 0.000778785 -3.32258710 8.91868e-04 1.38877e-02
## ASV10 137.11819 -1.08912e-03 0.000625235 -1.74194285 8.15184e-02 2.24950e-01
## ASV12 68.66647 1.18801e-03 0.000743032 1.59886882 1.09850e-01 2.60296e-01
## ASV13 1.03461 7.61080e-07 0.000505900 0.00150441 9.98800e-01 NA
## Genus
## <character>
## ASV7 Endobacter
## ASV8 Endobacter
## ASV9 1174-901-12
## ASV10 NA
## ASV12 Staphylococcus
## ASV13 Limosilactobacillus
####Generate a summary table of significant Betula ASVs from your continuous GDD model, listing their DESeq2 statistics and adding genus-level taxonomy for interpretation. ################################################################################
#-------------------------------------------------------
## INTRASPECIFIC: Betula
#----------------------------------------------------------
# Select the columns you want in the table
top_asv_table_bet_cont_trend <- significant_asvs_betula_contin_trend[, c("baseMean",
"log2FoldChange", "lfcSE", "stat", "pvalue", "padj")]
# Optionally, you can add the taxonomic information if available
top_asv_table_bet_cont_trend$Genus <- taxa_rdp[rownames(top_asv_table_bet_cont_trend),
"Genus"]
print(top_asv_table_bet_cont_trend)
## log2 fold change (MLE): GDD 5C scaled
## Wald test p-value: GDD 5C scaled
## DataFrame with 1732 rows and 7 columns
## baseMean log2FoldChange lfcSE stat pvalue padj
## <numeric> <numeric> <numeric> <numeric> <numeric> <numeric>
## ASV7 502.7143 2.12420833 0.415042 5.1180589 3.08696e-07 9.26089e-06
## ASV8 333.2000 3.83858633 0.354450 10.8297114 2.48939e-27 6.72134e-25
## ASV9 271.9714 2.03967276 0.413342 4.9345927 8.03182e-07 1.97145e-05
## ASV10 267.7714 0.50504654 0.311861 1.6194624 1.05348e-01 1.85737e-01
## ASV12 22.1143 -0.00799682 0.299532 -0.0266977 9.78701e-01 9.78701e-01
## ... ... ... ... ... ... ...
## ASV1786 1.00000 1.66599e-27 0.257801 6.46232e-27 1.000000 NA
## ASV1787 1.05714 6.44118e-02 0.252056 2.55546e-01 0.798302 NA
## ASV1788 1.05714 6.44118e-02 0.252056 2.55546e-01 0.798302 NA
## ASV1789 1.05714 6.44118e-02 0.252056 2.55546e-01 0.798302 NA
## ASV1790 1.00000 1.66599e-27 0.257801 6.46232e-27 1.000000 NA
## Genus
## <character>
## ASV7 Endobacter
## ASV8 Endobacter
## ASV9 1174-901-12
## ASV10 NA
## ASV12 Staphylococcus
## ... ...
## ASV1786 NA
## ASV1787 Conexibacter
## ASV1788 Methylobacterium-Met..
## ASV1789 NA
## ASV1790 NA
head(top_asv_table_bet_cont_trend)
## log2 fold change (MLE): GDD 5C scaled
## Wald test p-value: GDD 5C scaled
## DataFrame with 6 rows and 7 columns
## baseMean log2FoldChange lfcSE stat pvalue padj
## <numeric> <numeric> <numeric> <numeric> <numeric> <numeric>
## ASV7 502.7143 2.12421e+00 0.415042 5.11806e+00 3.08696e-07 9.26089e-06
## ASV8 333.2000 3.83859e+00 0.354450 1.08297e+01 2.48939e-27 6.72134e-25
## ASV9 271.9714 2.03967e+00 0.413342 4.93459e+00 8.03182e-07 1.97145e-05
## ASV10 267.7714 5.05047e-01 0.311861 1.61946e+00 1.05348e-01 1.85737e-01
## ASV12 22.1143 -7.99682e-03 0.299532 -2.66977e-02 9.78701e-01 9.78701e-01
## ASV13 1.0000 1.66599e-27 0.257801 6.46232e-27 1.00000e+00 NA
## Genus
## <character>
## ASV7 Endobacter
## ASV8 Endobacter
## ASV9 1174-901-12
## ASV10 NA
## ASV12 Staphylococcus
## ASV13 Limosilactobacillus
####Generate a summary table of significant Populus ASVs from your continuous GDD model, listing their DESeq2 statistics and adding genus-level taxonomy for interpretation. ################################################################################
#-------------------------------------------------------
## INTRASPECIFIC: Populus
#----------------------------------------------------------
# Select the columns you want in the table
top_asv_table_pop_cont_trend <- significant_asvs_populus_contin_trend[, c("baseMean",
"log2FoldChange", "lfcSE", "stat", "pvalue", "padj")]
# Optionally, you can add the taxonomic information if available
top_asv_table_pop_cont_trend$Genus <- taxa_rdp[rownames(top_asv_table_pop_cont_trend),
"Genus"]
print(top_asv_table_pop_cont_trend)
## log2 fold change (MLE): GDD 5C scaled
## Wald test p-value: GDD 5C scaled
## DataFrame with 1732 rows and 7 columns
## baseMean log2FoldChange lfcSE stat pvalue padj
## <numeric> <numeric> <numeric> <numeric> <numeric> <numeric>
## ASV7 3.02256 -0.805976 0.324142 -2.486489 NA NA
## ASV8 2.76172 -0.220395 0.291686 -0.755591 0.449894 0.588462
## ASV9 4.30244 0.246337 0.333524 0.738590 0.460156 0.596059
## ASV10 1.19329 -0.257293 0.237150 -1.084936 0.277950 NA
## ASV12 114.65234 0.810487 0.407944 1.986760 NA NA
## ... ... ... ... ... ... ...
## ASV1786 1.10541 -0.093718227 0.248051 -0.377818563 0.705565 NA
## ASV1787 1.04731 -0.000229578 0.257830 -0.000890425 0.999290 NA
## ASV1788 1.04731 -0.000229578 0.257830 -0.000890425 0.999290 NA
## ASV1789 1.04731 -0.000229578 0.257830 -0.000890425 0.999290 NA
## ASV1790 1.10541 0.081146748 0.251407 0.322770091 0.746869 NA
## Genus
## <character>
## ASV7 Endobacter
## ASV8 Endobacter
## ASV9 1174-901-12
## ASV10 NA
## ASV12 Staphylococcus
## ... ...
## ASV1786 NA
## ASV1787 Conexibacter
## ASV1788 Methylobacterium-Met..
## ASV1789 NA
## ASV1790 NA
head(top_asv_table_pop_cont_trend)
## log2 fold change (MLE): GDD 5C scaled
## Wald test p-value: GDD 5C scaled
## DataFrame with 6 rows and 7 columns
## baseMean log2FoldChange lfcSE stat pvalue padj
## <numeric> <numeric> <numeric> <numeric> <numeric> <numeric>
## ASV7 3.02256 -0.805976417 0.324142 -2.486488615 NA NA
## ASV8 2.76172 -0.220395331 0.291686 -0.755591088 0.449894 0.588462
## ASV9 4.30244 0.246337151 0.333524 0.738589936 0.460156 0.596059
## ASV10 1.19329 -0.257292520 0.237150 -1.084936463 0.277950 NA
## ASV12 114.65234 0.810487111 0.407944 1.986759926 NA NA
## ASV13 1.04731 -0.000229578 0.257830 -0.000890425 0.999290 NA
## Genus
## <character>
## ASV7 Endobacter
## ASV8 Endobacter
## ASV9 1174-901-12
## ASV10 NA
## ASV12 Staphylococcus
## ASV13 Limosilactobacillus
####Build two styled HTML tables (first 10 rows) for the Species main
effect and SpeciesxGDD interaction result sets, adding Genus from the
phyloseq taxonomy and the ASV ID, then displaying DESeq2
stats via kableExtra.
################################################################################
#-------------------------------------------------------
## FOR `asv_scaled_noPlants_Phenology_stats_LMM` (i.e.,
## `asv_scaled_noPlants_Phen_filt_LMM`)
#-------------------------------------------------------
# NOTE: Shows most abundant ASVs OVERALL!! Not b/w tree species!
# Select the columns you want in the table
top_asv_table_spp_LMM <- top_asv_table_spp_LMM[, c("baseMean", "log2FoldChange",
"lfcSE", "stat", "pvalue", "padj")]
top_asv_table_spp_interaction <- top_asv_table_spp_interaction[, c("baseMean", "log2FoldChange",
"lfcSE", "stat", "pvalue", "padj")]
# Get the rownames of the top ASVs
top_asv_names_LMM <- rownames(top_asv_table_spp_LMM)
top_asv_names_interaction <- rownames(top_asv_table_spp_interaction)
# Retrieve the taxonomic information for the top ASVs from 'tax_table'
top_asv_tax_LMM <- tax_table(ps_phen_asv_LMM)[top_asv_names_LMM, "Genus"]
top_asv_tax_interaction <- tax_table(ps_phen_asv_LMM)[top_asv_names_interaction,
"Genus"]
# Add the taxonomic information to the table
top_asv_table_spp_LMM$Genus <- top_asv_tax_LMM
top_asv_table_spp_interaction$Genus <- top_asv_tax_interaction
subset_top_asv_data_LMM <- top_asv_table_spp_LMM[1:10, ]
subset_top_asv_data_interaction <- top_asv_table_spp_interaction[1:10, ]
# Get the rownames of the top ASVs
top_asv_names_LMM <- rownames(top_asv_table_spp_LMM)
top_asv_names_interaction <- rownames(top_asv_table_spp_interaction)
# Add the ASV information to the table as the first column
top_asv_table_spp_LMM <- cbind(ASV = top_asv_names_LMM, top_asv_table_spp_LMM)
top_asv_table_spp_interaction <- cbind(ASV = top_asv_names_interaction, top_asv_table_spp_interaction)
# Now, top_asv_table_spp_LMM will have an 'ASV' column
library(knitr)
library(kableExtra)
# Convert the data frame to a kable object and format the table with custom
# styling
kable_table_LMM <- kable(subset_top_asv_data_LMM, format = "html", align = "c") %>%
kable_styling(bootstrap_options = "striped", full_width = TRUE) %>%
row_spec(1, background = "lightgrey") %>%
row_spec(seq(2, nrow(subset_top_asv_data_LMM), by = 2), background = "whitesmoke") %>%
row_spec(seq(3, nrow(subset_top_asv_data_LMM), by = 2), background = "white")
kable_table_interaction <- kable(subset_top_asv_data_interaction, format = "html",
align = "c") %>%
kable_styling(bootstrap_options = "striped", full_width = TRUE) %>%
row_spec(1, background = "lightgrey") %>%
row_spec(seq(2, nrow(subset_top_asv_data_interaction), by = 2), background = "whitesmoke") %>%
row_spec(seq(3, nrow(subset_top_asv_data_interaction), by = 2), background = "white")
# Display only the first 10 rows in your RMarkdown document
kable_table_LMM
| baseMean | log2FoldChange | lfcSE | stat | pvalue | padj | Genus | |
|---|---|---|---|---|---|---|---|
| ASV7 | 257.832435 | 0.3936066 | 1.2113655 | 0.3249280 | 0.7452356 | 0.8708748 | Endobacter |
| ASV8 | 171.268751 | -3.7078117 | 1.0853134 | -3.4163511 | 0.0006347 | 0.0254659 | Endobacter |
| ASV9 | 140.793389 | 1.1452676 | 1.2425856 | 0.9216811 | 0.3566949 | 0.6580407 | 1174-901-12 |
| ASV10 | 137.118185 | 6.2707595 | 0.9748294 | 6.4326734 | 0.0000000 | 0.0000000 | NA |
| ASV12 | 68.666466 | -0.5425867 | 1.1807009 | -0.4595463 | 0.6458419 | 0.8226796 | Staphylococcus |
| ASV13 | 1.034612 | 0.0012678 | 0.8034945 | 0.0015778 | 0.9987411 | NA | Limosilactobacillus |
| ASV14 | 78.954477 | 2.8943627 | 1.1018495 | 2.6268223 | 0.0086186 | 0.0953994 | 1174-901-12 |
| ASV15 | 1.034612 | 0.0012678 | 0.8034945 | 0.0015778 | 0.9987411 | NA | Bacillus |
| ASV16 | 1.078317 | -0.0795551 | 0.8020768 | -0.0991864 | 0.9209903 | NA | Escherichia-Shigella |
| ASV17 | 58.620132 | -0.5037113 | 4.3669477 | -0.1153463 | NA | NA | Massilia |
kable_table_interaction
| baseMean | log2FoldChange | lfcSE | stat | pvalue | padj | Genus | |
|---|---|---|---|---|---|---|---|
| ASV7 | 257.832435 | -0.0042424 | 0.0007756 | -5.4701101 | 0.0000000 | 0.0000033 | Endobacter |
| ASV8 | 171.268751 | -0.0058447 | 0.0006749 | -8.6599475 | 0.0000000 | 0.0000000 | Endobacter |
| ASV9 | 140.793389 | -0.0025876 | 0.0007788 | -3.3225871 | 0.0008919 | 0.0138877 | 1174-901-12 |
| ASV10 | 137.118185 | -0.0010891 | 0.0006252 | -1.7419428 | 0.0815184 | 0.2249496 | NA |
| ASV12 | 68.666466 | 0.0011880 | 0.0007430 | 1.5988688 | 0.1098498 | 0.2602962 | Staphylococcus |
| ASV13 | 1.034612 | 0.0000008 | 0.0005059 | 0.0015044 | 0.9987997 | NA | Limosilactobacillus |
| ASV14 | 78.954477 | -0.0019100 | 0.0006751 | -2.8294635 | 0.0046626 | 0.0376463 | 1174-901-12 |
| ASV15 | 1.034612 | 0.0000008 | 0.0005059 | 0.0015044 | 0.9987997 | NA | Bacillus |
| ASV16 | 1.078317 | -0.0001356 | 0.0004995 | -0.2714868 | 0.7860166 | NA | Escherichia-Shigella |
| ASV17 | 58.620132 | -0.0002825 | 0.0027437 | -0.1029463 | NA | NA | Massilia |
####Build a styled HTML table (first 10 rows) of Betula intraspecific GDD-trend ASVs, keeping key DESeq2 stats, appending Genus from ps_betula, adding the ASV ID column, and displaying it via kableExtra. ################################################################################
#-------------------------------------------------------
## INTRAspecific: Betula
#-------------------------------------------------------
# NOTE: Shows most abundant ASVs OVERALL!! Not b/w GDDs!
# Select the columns you want in the table
top_asv_table_bet_cont_trend <- top_asv_table_bet_cont_trend[, c("baseMean", "log2FoldChange",
"lfcSE", "stat", "pvalue", "padj")]
# Get the rownames of the top ASVs
top_asv_names_bet_cont_trend <- rownames(top_asv_table_bet_cont_trend)
# Retrieve the taxonomic information for the top ASVs from 'tax_table'
top_asv_tax_bet_cont_trend <- tax_table(ps_betula)[top_asv_names_bet_cont_trend,
"Genus"]
# Add the taxonomic information to the table
top_asv_table_bet_cont_trend$Genus <- top_asv_tax_bet_cont_trend
subset_top_asv_data_bet_cont_trend <- top_asv_table_bet_cont_trend[1:10, ]
# Get the rownames of the top ASVs
top_asv_names_bet_cont_trend <- rownames(top_asv_table_bet_cont_trend)
# Add the ASV information to the table as the first column
top_asv_table_bet_cont_trend <- cbind(ASV = top_asv_names_bet_cont_trend, top_asv_table_bet_cont_trend)
library(knitr)
library(kableExtra)
# Convert the data frame to a kable object and format the table with custom
# styling
kable_table_bet_cont_trend <- kable(subset_top_asv_data_bet_cont_trend, format = "html",
align = "c") %>%
kable_styling(bootstrap_options = "striped", full_width = TRUE) %>%
row_spec(1, background = "lightgrey") %>%
row_spec(seq(2, nrow(subset_top_asv_data_bet_cont_trend), by = 2), background = "whitesmoke") %>%
row_spec(seq(3, nrow(subset_top_asv_data_bet_cont_trend), by = 2), background = "white")
kable_table_bet_cont_trend
| baseMean | log2FoldChange | lfcSE | stat | pvalue | padj | Genus | |
|---|---|---|---|---|---|---|---|
| ASV7 | 502.714286 | 2.1242083 | 0.4150418 | 5.1180589 | 0.0000003 | 0.0000093 | Endobacter |
| ASV8 | 333.200000 | 3.8385863 | 0.3544495 | 10.8297114 | 0.0000000 | 0.0000000 | Endobacter |
| ASV9 | 271.971429 | 2.0396728 | 0.4133417 | 4.9345927 | 0.0000008 | 0.0000197 | 1174-901-12 |
| ASV10 | 267.771429 | 0.5050465 | 0.3118606 | 1.6194624 | 0.1053478 | 0.1857369 | NA |
| ASV12 | 22.114286 | -0.0079968 | 0.2995319 | -0.0266977 | 0.9787008 | 0.9787008 | Staphylococcus |
| ASV13 | 1.000000 | 0.0000000 | 0.2578008 | 0.0000000 | 1.0000000 | NA | Limosilactobacillus |
| ASV14 | 153.228571 | 1.8734110 | 0.3504879 | 5.3451520 | 0.0000001 | 0.0000035 | 1174-901-12 |
| ASV15 | 1.000000 | 0.0000000 | 0.2578008 | 0.0000000 | 1.0000000 | NA | Bacillus |
| ASV16 | 1.085714 | 0.0944411 | 0.2496392 | 0.3783105 | 0.7051999 | NA | Escherichia-Shigella |
| ASV17 | 92.885714 | 3.4399251 | 0.5131737 | 6.7032371 | NA | NA | Massilia |
####Build a styled HTML table (first 10 rows) of Populus intraspecific GDD-trend ASVs, keeping key DESeq2 stats, appending Genus from ps_populus, adding the ASV ID column, and displaying it via kableExtra. ################################################################################
#-------------------------------------------------------
## INTRAspecific: Populus
#-------------------------------------------------------
# NOTE: Shows most abundant ASVs OVERALL!! Not b/w GDDs!
# Select the columns you want in the table
top_asv_table_pop_cont_trend <- top_asv_table_pop_cont_trend[, c("baseMean", "log2FoldChange",
"lfcSE", "stat", "pvalue", "padj")]
# Get the rownames of the top ASVs
top_asv_names_pop_cont_trend <- rownames(top_asv_table_pop_cont_trend)
# Retrieve the taxonomic information for the top ASVs from 'tax_table'
top_asv_tax_pop_cont_trend <- tax_table(ps_populus)[top_asv_names_pop_cont_trend,
"Genus"]
# Add the taxonomic information to the table
top_asv_table_pop_cont_trend$Genus <- top_asv_tax_pop_cont_trend
subset_top_asv_data_pop_cont_trend <- top_asv_table_pop_cont_trend[1:10, ]
# Get the rownames of the top ASVs
top_asv_names_pop_cont_trend <- rownames(top_asv_table_pop_cont_trend)
# Add the ASV information to the table as the first column
top_asv_table_pop_cont_trend <- cbind(ASV = top_asv_names_pop_cont_trend, top_asv_table_pop_cont_trend)
library(knitr)
library(kableExtra)
# Convert the data frame to a kable object and format the table with custom
# styling
kable_table_pop_cont_trend <- kable(subset_top_asv_data_pop_cont_trend, format = "html",
align = "c") %>%
kable_styling(bootstrap_options = "striped", full_width = TRUE) %>%
row_spec(1, background = "lightgrey") %>%
row_spec(seq(2, nrow(subset_top_asv_data_pop_cont_trend), by = 2), background = "whitesmoke") %>%
row_spec(seq(3, nrow(subset_top_asv_data_pop_cont_trend), by = 2), background = "white")
kable_table_pop_cont_trend
| baseMean | log2FoldChange | lfcSE | stat | pvalue | padj | Genus | |
|---|---|---|---|---|---|---|---|
| ASV7 | 3.022562 | -0.8059764 | 0.3241424 | -2.4864886 | NA | NA | Endobacter |
| ASV8 | 2.761722 | -0.2203953 | 0.2916860 | -0.7555911 | 0.4498944 | 0.5884619 | Endobacter |
| ASV9 | 4.302435 | 0.2463372 | 0.3335236 | 0.7385899 | 0.4601560 | 0.5960594 | 1174-901-12 |
| ASV10 | 1.193288 | -0.2572925 | 0.2371499 | -1.0849365 | 0.2779498 | NA | NA |
| ASV12 | 114.652343 | 0.8104871 | 0.4079442 | 1.9867599 | NA | NA | Staphylococcus |
| ASV13 | 1.047311 | -0.0002296 | 0.2578300 | -0.0008904 | 0.9992895 | NA | Limosilactobacillus |
| ASV14 | 1.717181 | 0.5500226 | 0.2566557 | 2.1430365 | 0.0321102 | 0.1346961 | 1174-901-12 |
| ASV15 | 1.047311 | -0.0002296 | 0.2578300 | -0.0008904 | 0.9992895 | NA | Bacillus |
| ASV16 | 1.047311 | -0.0002296 | 0.2578300 | -0.0008904 | 0.9992895 | NA | Escherichia-Shigella |
| ASV17 | 22.585706 | 1.5207820 | 0.4348607 | 3.4971707 | NA | NA | Massilia |
# Export the table to a CSV file
write.csv(top_asv_table_bet_cont_trend, file = "top_asv_table_bet_cont_gdd_trend.csv",
row.names = FALSE)
write.csv(top_asv_table_pop_cont_trend, file = "top_asv_table_pop_cont_gdd_trend.csv",
row.names = FALSE)
# Export the table to a tab-separated TXT file
write.table(top_asv_table_bet_cont_trend, file = "top_asv_table_bet_cont_gdd_trend.txt",
sep = "\t", row.names = FALSE)
write.table(top_asv_table_pop_cont_trend, file = "top_asv_table_top_asv_table_pop_cont_gdd_trend.txt",
sep = "\t", row.names = FALSE)
####Filter significant DESeq2 hits (padj < 0.05) for the Species main effect and the SpeciesxGDD interaction; merges each set with full taxonomy from the phyloseq object, selects and renames key columns (taxa ranks + L2FC/p-values), adds the ASV IDs, takes the first 10 rows of each, and renders two styled HTML summary tables. ################################################################################
#-------------------------------------------------------
## FOR `asv_scaled_noPlants_Phenology_stats_LMM` (i.e.,
## `asv_scaled_noPlants_Phen_filt_LMM`)
#-------------------------------------------------------
# Filter significant results (you can adjust the threshold for significance as
# needed)
significant_results_spp_LMM <- subset(results_species_diff_abund_LMM, padj < 0.05)
# significant_results_spp_LMM <- subset(results_species_diff_abund_LMM)
significant_results_spp_interaction <- subset(results_interaction_diff_abund_LMM,
padj < 0.05)
# significant_results_spp_interaction <-
# subset(results_species_diff_abund_interaction)
# Get ASV names of differentially abundant ASVs
significant_asv_names_spp_LMM <- rownames(significant_results_spp_LMM)
significant_asv_names_spp_interaction <- rownames(significant_results_spp_interaction)
# Get the taxonomic information for the significant ASVs
significant_asv_tax_spp_LMM <- tax_table(ps_phen_asv_LMM)[significant_asv_names_spp_LMM,
]
significant_asv_tax_spp_interaction <- tax_table(ps_phen_asv_LMM)[significant_asv_names_spp_interaction,
]
# Merge the results with taxonomic information
significant_results_table_spp_LMM <- cbind(significant_asv_tax_spp_LMM, significant_results_spp_LMM)
significant_results_table_spp_interaction <- cbind(significant_asv_tax_spp_interaction,
significant_results_spp_interaction)
# Select columns of interest for the final table
final_asv_table_spp_LMM <- significant_results_table_spp_LMM[, c("Kingdom", "Phylum",
"Class", "Order", "Family", "Genus", "Species", "log2FoldChange", "pvalue", "padj")]
final_asv_table_spp_interaction <- significant_results_table_spp_interaction[, c("Kingdom",
"Phylum", "Class", "Order", "Family", "Genus", "Species", "log2FoldChange", "pvalue",
"padj")]
# Rename the columns for better presentation
colnames(final_asv_table_spp_LMM) <- c("Kingdom", "Phylum", "Class", "Order", "Family",
"Genus", "Species", "Log2 Fold Change", "P-value", "Adjusted P-value")
colnames(final_asv_table_spp_interaction) <- c("Kingdom", "Phylum", "Class", "Order",
"Family", "Genus", "Species", "Log2 Fold Change", "P-value", "Adjusted P-value")
subset_final_asv_table_LMM <- final_asv_table_spp_LMM[1:10, ]
subset_final_asv_table_interaction <- final_asv_table_spp_interaction[1:10, ]
# Get ASV names of differentially abundant ASVs
significant_asv_names_spp_LMM <- rownames(significant_results_spp_LMM)
significant_asv_names_spp_interaction <- rownames(significant_results_spp_interaction)
# Add the ASV information to the table as the first column
final_asv_table_spp_LMM <- cbind(ASV = significant_asv_names_spp_LMM, final_asv_table_spp_LMM)
final_asv_table_spp_interaction <- cbind(ASV = significant_asv_names_spp_interaction,
final_asv_table_spp_interaction)
# Display the final table
kable(subset_final_asv_table_LMM, format = "html", align = "c") %>%
kable_styling(bootstrap_options = "striped", full_width = TRUE)
| Kingdom | Phylum | Class | Order | Family | Genus | Species | Log2.Fold.Change | P.value | Adjusted.P.value | |
|---|---|---|---|---|---|---|---|---|---|---|
| ASV8 | Bacteria | Proteobacteria | Alphaproteobacteria | Acetobacterales | Acetobacteraceae | Endobacter | NA | -3.707812 | 0.0006347 | 0.0254659 |
| ASV10 | Bacteria | Proteobacteria | NA | NA | NA | NA | NA | 6.270759 | 0.0000000 | 0.0000000 |
| ASV33 | Bacteria | Actinobacteriota | Actinobacteria | Kineosporiales | Kineosporiaceae | Quadrisphaera | NA | -4.277465 | 0.0000393 | 0.0031568 |
| ASV36 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhodobacterales | Rhodobacteraceae | Rubellimicrobium | NA | -4.008784 | 0.0004938 | 0.0226452 |
| ASV39 | Bacteria | Proteobacteria | Alphaproteobacteria | Acetobacterales | Acetobacteraceae | Endobacter | NA | 3.938017 | 0.0010118 | 0.0295247 |
| ASV44 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | Methylobacterium-Methylorubrum | NA | -4.281137 | 0.0001693 | 0.0090556 |
| ASV81 | Bacteria | Bacteroidota | Bacteroidia | Cytophagales | Hymenobacteraceae | Hymenobacter | NA | -4.182536 | 0.0000668 | 0.0042861 |
| ASV86 | Bacteria | Proteobacteria | Gammaproteobacteria | Enterobacterales | Erwiniaceae | NA | NA | -5.989222 | 0.0000002 | 0.0000324 |
| ASV106 | Bacteria | Actinobacteriota | Actinobacteria | Frankiales | Geodermatophilaceae | Blastococcus | NA | -5.256323 | 0.0000022 | 0.0002357 |
| ASV107 | Bacteria | Proteobacteria | Alphaproteobacteria | Sphingomonadales | Sphingomonadaceae | Sphingomonas | NA | -3.220445 | 0.0014022 | 0.0346237 |
kable(subset_final_asv_table_interaction, format = "html", align = "c") %>%
kable_styling(bootstrap_options = "striped", full_width = TRUE)
| Kingdom | Phylum | Class | Order | Family | Genus | Species | Log2.Fold.Change | P.value | Adjusted.P.value | |
|---|---|---|---|---|---|---|---|---|---|---|
| ASV7 | Bacteria | Proteobacteria | Alphaproteobacteria | Acetobacterales | Acetobacteraceae | Endobacter | NA | -0.0042424 | 0.0000000 | 0.0000033 |
| ASV8 | Bacteria | Proteobacteria | Alphaproteobacteria | Acetobacterales | Acetobacteraceae | Endobacter | NA | -0.0058447 | 0.0000000 | 0.0000000 |
| ASV9 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | 1174-901-12 | NA | -0.0025876 | 0.0008919 | 0.0138877 |
| ASV14 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | 1174-901-12 | NA | -0.0019100 | 0.0046626 | 0.0376463 |
| ASV28 | Bacteria | Myxococcota | Myxococcia | Myxococcales | Myxococcaceae | P3OB-42 | NA | -0.0038803 | 0.0000001 | 0.0000043 |
| ASV29 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | 1174-901-12 | NA | -0.0031306 | 0.0000238 | 0.0008641 |
| ASV35 | Bacteria | NA | NA | NA | NA | NA | NA | -0.0021798 | 0.0014485 | 0.0197362 |
| ASV37 | Bacteria | Myxococcota | Myxococcia | Myxococcales | Myxococcaceae | P3OB-42 | NA | -0.0039060 | 0.0000000 | 0.0000033 |
| ASV47 | Bacteria | Myxococcota | Myxococcia | Myxococcales | Myxococcaceae | P3OB-42 | NA | -0.0035111 | 0.0000024 | 0.0001054 |
| ASV49 | Bacteria | Myxococcota | Myxococcia | Myxococcales | Myxococcaceae | P3OB-42 | NA | -0.0030469 | 0.0000660 | 0.0015980 |
####Build a Betula-only (Intraspecific) results table for ASVs with significant continuous GDD trends (padj < 0.05): pulls ASV IDs, joins full taxonomy from ps_betula, selects/renames key DESeq2 stats, keeps the first 47 rows, adds an ASV column, and renders a styled HTML table with kableExtra. ################################################################################
#-------------------------------------------------------
## INTRAspecific: Betula
#-------------------------------------------------------
# Filter significant results (you can adjust the threshold for significance as
# needed)
significant_results_bet_cont_trend <- subset(results_gdd_trend_betula, padj < 0.05)
# Get ASV names of differentially abundant ASVs
significant_asv_names_bet_cont_trend <- rownames(significant_results_bet_cont_trend)
# Get the taxonomic information for the significant ASVs
significant_asv_tax_bet_cont_trend <- tax_table(ps_betula)[significant_asv_names_bet_cont_trend,
]
# Merge the results with taxonomic information
significant_results_table_bet_cont_trend <- cbind(significant_asv_tax_bet_cont_trend,
significant_results_bet_cont_trend)
# Select columns of interest for the final table
final_asv_table_bet_cont_trend <- significant_results_table_bet_cont_trend[, c("Kingdom",
"Phylum", "Class", "Order", "Family", "Genus", "Species", "log2FoldChange", "pvalue",
"padj")]
# Rename the columns for better presentation
colnames(final_asv_table_bet_cont_trend) <- c("Kingdom", "Phylum", "Class", "Order",
"Family", "Genus", "Species", "Log2 Fold Change", "P-value", "Adjusted P-value")
subset_final_asv_table_bet_cont_trend <- final_asv_table_bet_cont_trend[1:47, ]
# Get ASV names of differentially abundant ASVs
significant_asv_names_bet_cont_trend <- rownames(significant_results_bet_cont_trend)
# Add the ASV information to the table as the first column
final_asv_table_bet_cont_trend <- cbind(ASV = significant_asv_names_bet_cont_trend,
final_asv_table_bet_cont_trend)
# Display the final table
kable(subset_final_asv_table_bet_cont_trend, format = "html", align = "c") %>%
kable_styling(bootstrap_options = "striped", full_width = TRUE)
| Kingdom | Phylum | Class | Order | Family | Genus | Species | Log2.Fold.Change | P.value | Adjusted.P.value | |
|---|---|---|---|---|---|---|---|---|---|---|
| ASV7 | Bacteria | Proteobacteria | Alphaproteobacteria | Acetobacterales | Acetobacteraceae | Endobacter | NA | 2.1242083 | 0.0000003 | 0.0000093 |
| ASV8 | Bacteria | Proteobacteria | Alphaproteobacteria | Acetobacterales | Acetobacteraceae | Endobacter | NA | 3.8385863 | 0.0000000 | 0.0000000 |
| ASV9 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | 1174-901-12 | NA | 2.0396728 | 0.0000008 | 0.0000197 |
| ASV14 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | 1174-901-12 | NA | 1.8734110 | 0.0000001 | 0.0000035 |
| ASV19 | Bacteria | Proteobacteria | NA | NA | NA | NA | NA | 1.2588944 | 0.0025276 | 0.0189571 |
| ASV22 | Bacteria | Proteobacteria | Gammaproteobacteria | Burkholderiales | Comamonadaceae | Pelomonas | NA | 1.6566167 | 0.0000289 | 0.0004592 |
| ASV25 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | 1174-901-12 | NA | 1.3497202 | 0.0009713 | 0.0090435 |
| ASV28 | Bacteria | Myxococcota | Myxococcia | Myxococcales | Myxococcaceae | P3OB-42 | NA | 2.8095111 | 0.0000000 | 0.0000000 |
| ASV29 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | 1174-901-12 | NA | 1.5748891 | 0.0000614 | 0.0008731 |
| ASV35 | Bacteria | NA | NA | NA | NA | NA | NA | 1.5432206 | 0.0000225 | 0.0003791 |
| ASV37 | Bacteria | Myxococcota | Myxococcia | Myxococcales | Myxococcaceae | P3OB-42 | NA | 2.6219493 | 0.0000000 | 0.0000000 |
| ASV42 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | 1174-901-12 | NA | 1.3654526 | 0.0002046 | 0.0023021 |
| ASV46 | Bacteria | Proteobacteria | Alphaproteobacteria | Sphingomonadales | Sphingomonadaceae | Sphingomonas | NA | 1.1117519 | 0.0043234 | 0.0299313 |
| ASV47 | Bacteria | Myxococcota | Myxococcia | Myxococcales | Myxococcaceae | P3OB-42 | NA | 2.4085920 | 0.0000000 | 0.0000005 |
| ASV49 | Bacteria | Myxococcota | Myxococcia | Myxococcales | Myxococcaceae | P3OB-42 | NA | 2.1533497 | 0.0000005 | 0.0000134 |
| ASV54 | Bacteria | Proteobacteria | Alphaproteobacteria | Sphingomonadales | Sphingomonadaceae | Sphingomonas | NA | 1.0075690 | 0.0064738 | 0.0406495 |
| ASV62 | Bacteria | Proteobacteria | Gammaproteobacteria | Burkholderiales | Oxalobacteraceae | Massilia | NA | 1.7959536 | 0.0000001 | 0.0000041 |
| ASV64 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | Methylocella | NA | 1.8621600 | 0.0000001 | 0.0000025 |
| ASV69 | Bacteria | Proteobacteria | Gammaproteobacteria | Pseudomonadales | Moraxellaceae | Enhydrobacter | aerosaccus | 1.6977143 | 0.0000078 | 0.0001751 |
| ASV75 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | Methylobacterium-Methylorubrum | NA | 1.5502567 | 0.0000102 | 0.0001901 |
| ASV79 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | 1174-901-12 | NA | 1.3426075 | 0.0000959 | 0.0012948 |
| ASV84 | Bacteria | Myxococcota | Myxococcia | Myxococcales | Myxococcaceae | P3OB-42 | NA | 1.7524939 | 0.0000001 | 0.0000025 |
| ASV91 | Bacteria | Proteobacteria | Alphaproteobacteria | Acetobacterales | Acetobacteraceae | Endobacter | NA | 1.7629056 | 0.0000087 | 0.0001817 |
| ASV95 | Bacteria | Acidobacteriota | Acidobacteriae | Acidobacteriales | Acidobacteriaceae (Subgroup 1) | Bryocella | NA | 0.8286858 | 0.0079156 | 0.0454725 |
| ASV97 | Bacteria | Proteobacteria | Gammaproteobacteria | Burkholderiales | Oxalobacteraceae | Massilia | NA | 1.1950741 | 0.0015193 | 0.0124308 |
| ASV102 | Bacteria | Acidobacteriota | Acidobacteriae | Acidobacteriales | Acidobacteriaceae (Subgroup 1) | Terriglobus | NA | 1.0655759 | 0.0028745 | 0.0209762 |
| ASV115 | Bacteria | Proteobacteria | Gammaproteobacteria | Gammaproteobacteria Incertae Sedis | Unknown Family | Candidatus Ovatusbacter | NA | 1.5398009 | 0.0000106 | 0.0001901 |
| ASV119 | Bacteria | NA | NA | NA | NA | NA | NA | 1.3889912 | 0.0001635 | 0.0019247 |
| ASV135 | Bacteria | Actinobacteriota | Actinobacteria | Micrococcales | Micrococcaceae | Rothia | mucilaginosa | -0.6454099 | 0.0051319 | 0.0346400 |
| ASV137 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | 1174-901-12 | NA | 1.0531623 | 0.0010497 | 0.0094472 |
| ASV160 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | Methylocella | NA | 1.2631504 | 0.0001640 | 0.0019247 |
| ASV161 | Bacteria | Proteobacteria | Gammaproteobacteria | NA | NA | NA | NA | 1.2397522 | 0.0000609 | 0.0008731 |
| ASV162 | Bacteria | Actinobacteriota | Actinobacteria | Micrococcales | Microbacteriaceae | Frondihabitans | NA | 0.8640341 | 0.0072393 | 0.0434356 |
| ASV166 | Bacteria | Proteobacteria | Alphaproteobacteria | NA | NA | NA | NA | 1.1059072 | 0.0004362 | 0.0045303 |
| ASV173 | Bacteria | Proteobacteria | Gammaproteobacteria | Enterobacterales | Enterobacteriaceae | Klebsiella | NA | 1.1625871 | 0.0011749 | 0.0099130 |
| ASV174 | Bacteria | Proteobacteria | Alphaproteobacteria | NA | NA | NA | NA | 0.8903671 | 0.0063681 | 0.0406495 |
| ASV180 | Bacteria | Bacteroidota | Bacteroidia | Cytophagales | Hymenobacteraceae | Hymenobacter | NA | 1.2323092 | 0.0002510 | 0.0027108 |
| ASV188 | Bacteria | Bdellovibrionota | Oligoflexia | 0319-6G20 | NA | NA | NA | 1.2830481 | 0.0001251 | 0.0016087 |
| ASV206 | Bacteria | Proteobacteria | Alphaproteobacteria | Acetobacterales | Acetobacteraceae | Acidiphilium | NA | 1.0148923 | 0.0020717 | 0.0159817 |
| ASV211 | Bacteria | Firmicutes | Bacilli | Bacillales | NA | NA | NA | -0.7404652 | 0.0060406 | 0.0397792 |
| ASV215 | Bacteria | Actinobacteriota | Actinobacteria | Micrococcales | Micrococcaceae | Pseudarthrobacter | NA | -0.9137905 | 0.0016382 | 0.0130093 |
| ASV233 | Bacteria | Myxococcota | Myxococcia | Myxococcales | Myxococcaceae | P3OB-42 | NA | 1.0199881 | 0.0007655 | 0.0076554 |
| ASV265 | Bacteria | Proteobacteria | Alphaproteobacteria | Acetobacterales | Acetobacteraceae | Endobacter | NA | 1.0066406 | 0.0011081 | 0.0096515 |
| ASV379 | Bacteria | Firmicutes | Bacilli | Lactobacillales | Streptococcaceae | Streptococcus | NA | -0.9276198 | 0.0009516 | 0.0090435 |
| ASV383 | Bacteria | Proteobacteria | Gammaproteobacteria | Enterobacterales | Enterobacteriaceae | Klebsiella | NA | -0.6208105 | 0.0075281 | 0.0441870 |
| ASV405 | Bacteria | Proteobacteria | Alphaproteobacteria | Acetobacterales | Acetobacteraceae | NA | NA | 0.8066206 | 0.0070469 | 0.0432421 |
| ASV492 | Bacteria | Proteobacteria | Gammaproteobacteria | CCD24 | NA | NA | NA | -0.6639646 | 0.0081344 | 0.0457559 |
# NOT subset; FULL Table (Betula):
# Display the final table
kable(final_asv_table_bet_cont_trend, format = "html", align = "c") %>%
kable_styling(bootstrap_options = "striped", full_width = TRUE)
| ASV | Kingdom | Phylum | Class | Order | Family | Genus | Species | Log2.Fold.Change | P.value | Adjusted.P.value |
|---|---|---|---|---|---|---|---|---|---|---|
| ASV7 | Bacteria | Proteobacteria | Alphaproteobacteria | Acetobacterales | Acetobacteraceae | Endobacter | NA | 2.1242083 | 0.0000003 | 0.0000093 |
| ASV8 | Bacteria | Proteobacteria | Alphaproteobacteria | Acetobacterales | Acetobacteraceae | Endobacter | NA | 3.8385863 | 0.0000000 | 0.0000000 |
| ASV9 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | 1174-901-12 | NA | 2.0396728 | 0.0000008 | 0.0000197 |
| ASV14 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | 1174-901-12 | NA | 1.8734110 | 0.0000001 | 0.0000035 |
| ASV19 | Bacteria | Proteobacteria | NA | NA | NA | NA | NA | 1.2588944 | 0.0025276 | 0.0189571 |
| ASV22 | Bacteria | Proteobacteria | Gammaproteobacteria | Burkholderiales | Comamonadaceae | Pelomonas | NA | 1.6566167 | 0.0000289 | 0.0004592 |
| ASV25 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | 1174-901-12 | NA | 1.3497202 | 0.0009713 | 0.0090435 |
| ASV28 | Bacteria | Myxococcota | Myxococcia | Myxococcales | Myxococcaceae | P3OB-42 | NA | 2.8095111 | 0.0000000 | 0.0000000 |
| ASV29 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | 1174-901-12 | NA | 1.5748891 | 0.0000614 | 0.0008731 |
| ASV35 | Bacteria | NA | NA | NA | NA | NA | NA | 1.5432206 | 0.0000225 | 0.0003791 |
| ASV37 | Bacteria | Myxococcota | Myxococcia | Myxococcales | Myxococcaceae | P3OB-42 | NA | 2.6219493 | 0.0000000 | 0.0000000 |
| ASV42 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | 1174-901-12 | NA | 1.3654526 | 0.0002046 | 0.0023021 |
| ASV46 | Bacteria | Proteobacteria | Alphaproteobacteria | Sphingomonadales | Sphingomonadaceae | Sphingomonas | NA | 1.1117519 | 0.0043234 | 0.0299313 |
| ASV47 | Bacteria | Myxococcota | Myxococcia | Myxococcales | Myxococcaceae | P3OB-42 | NA | 2.4085920 | 0.0000000 | 0.0000005 |
| ASV49 | Bacteria | Myxococcota | Myxococcia | Myxococcales | Myxococcaceae | P3OB-42 | NA | 2.1533497 | 0.0000005 | 0.0000134 |
| ASV54 | Bacteria | Proteobacteria | Alphaproteobacteria | Sphingomonadales | Sphingomonadaceae | Sphingomonas | NA | 1.0075690 | 0.0064738 | 0.0406495 |
| ASV62 | Bacteria | Proteobacteria | Gammaproteobacteria | Burkholderiales | Oxalobacteraceae | Massilia | NA | 1.7959536 | 0.0000001 | 0.0000041 |
| ASV64 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | Methylocella | NA | 1.8621600 | 0.0000001 | 0.0000025 |
| ASV69 | Bacteria | Proteobacteria | Gammaproteobacteria | Pseudomonadales | Moraxellaceae | Enhydrobacter | aerosaccus | 1.6977143 | 0.0000078 | 0.0001751 |
| ASV75 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | Methylobacterium-Methylorubrum | NA | 1.5502567 | 0.0000102 | 0.0001901 |
| ASV79 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | 1174-901-12 | NA | 1.3426075 | 0.0000959 | 0.0012948 |
| ASV84 | Bacteria | Myxococcota | Myxococcia | Myxococcales | Myxococcaceae | P3OB-42 | NA | 1.7524939 | 0.0000001 | 0.0000025 |
| ASV91 | Bacteria | Proteobacteria | Alphaproteobacteria | Acetobacterales | Acetobacteraceae | Endobacter | NA | 1.7629056 | 0.0000087 | 0.0001817 |
| ASV95 | Bacteria | Acidobacteriota | Acidobacteriae | Acidobacteriales | Acidobacteriaceae (Subgroup 1) | Bryocella | NA | 0.8286858 | 0.0079156 | 0.0454725 |
| ASV97 | Bacteria | Proteobacteria | Gammaproteobacteria | Burkholderiales | Oxalobacteraceae | Massilia | NA | 1.1950741 | 0.0015193 | 0.0124308 |
| ASV102 | Bacteria | Acidobacteriota | Acidobacteriae | Acidobacteriales | Acidobacteriaceae (Subgroup 1) | Terriglobus | NA | 1.0655759 | 0.0028745 | 0.0209762 |
| ASV115 | Bacteria | Proteobacteria | Gammaproteobacteria | Gammaproteobacteria Incertae Sedis | Unknown Family | Candidatus Ovatusbacter | NA | 1.5398009 | 0.0000106 | 0.0001901 |
| ASV119 | Bacteria | NA | NA | NA | NA | NA | NA | 1.3889912 | 0.0001635 | 0.0019247 |
| ASV135 | Bacteria | Actinobacteriota | Actinobacteria | Micrococcales | Micrococcaceae | Rothia | mucilaginosa | -0.6454099 | 0.0051319 | 0.0346400 |
| ASV137 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | 1174-901-12 | NA | 1.0531623 | 0.0010497 | 0.0094472 |
| ASV160 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | Methylocella | NA | 1.2631504 | 0.0001640 | 0.0019247 |
| ASV161 | Bacteria | Proteobacteria | Gammaproteobacteria | NA | NA | NA | NA | 1.2397522 | 0.0000609 | 0.0008731 |
| ASV162 | Bacteria | Actinobacteriota | Actinobacteria | Micrococcales | Microbacteriaceae | Frondihabitans | NA | 0.8640341 | 0.0072393 | 0.0434356 |
| ASV166 | Bacteria | Proteobacteria | Alphaproteobacteria | NA | NA | NA | NA | 1.1059072 | 0.0004362 | 0.0045303 |
| ASV173 | Bacteria | Proteobacteria | Gammaproteobacteria | Enterobacterales | Enterobacteriaceae | Klebsiella | NA | 1.1625871 | 0.0011749 | 0.0099130 |
| ASV174 | Bacteria | Proteobacteria | Alphaproteobacteria | NA | NA | NA | NA | 0.8903671 | 0.0063681 | 0.0406495 |
| ASV180 | Bacteria | Bacteroidota | Bacteroidia | Cytophagales | Hymenobacteraceae | Hymenobacter | NA | 1.2323092 | 0.0002510 | 0.0027108 |
| ASV188 | Bacteria | Bdellovibrionota | Oligoflexia | 0319-6G20 | NA | NA | NA | 1.2830481 | 0.0001251 | 0.0016087 |
| ASV206 | Bacteria | Proteobacteria | Alphaproteobacteria | Acetobacterales | Acetobacteraceae | Acidiphilium | NA | 1.0148923 | 0.0020717 | 0.0159817 |
| ASV211 | Bacteria | Firmicutes | Bacilli | Bacillales | NA | NA | NA | -0.7404652 | 0.0060406 | 0.0397792 |
| ASV215 | Bacteria | Actinobacteriota | Actinobacteria | Micrococcales | Micrococcaceae | Pseudarthrobacter | NA | -0.9137905 | 0.0016382 | 0.0130093 |
| ASV233 | Bacteria | Myxococcota | Myxococcia | Myxococcales | Myxococcaceae | P3OB-42 | NA | 1.0199881 | 0.0007655 | 0.0076554 |
| ASV265 | Bacteria | Proteobacteria | Alphaproteobacteria | Acetobacterales | Acetobacteraceae | Endobacter | NA | 1.0066406 | 0.0011081 | 0.0096515 |
| ASV379 | Bacteria | Firmicutes | Bacilli | Lactobacillales | Streptococcaceae | Streptococcus | NA | -0.9276198 | 0.0009516 | 0.0090435 |
| ASV383 | Bacteria | Proteobacteria | Gammaproteobacteria | Enterobacterales | Enterobacteriaceae | Klebsiella | NA | -0.6208105 | 0.0075281 | 0.0441870 |
| ASV405 | Bacteria | Proteobacteria | Alphaproteobacteria | Acetobacterales | Acetobacteraceae | NA | NA | 0.8066206 | 0.0070469 | 0.0432421 |
| ASV492 | Bacteria | Proteobacteria | Gammaproteobacteria | CCD24 | NA | NA | NA | -0.6639646 | 0.0081344 | 0.0457559 |
| ASV519 | Bacteria | Actinobacteriota | Actinobacteria | Corynebacteriales | Dietziaceae | Dietzia | NA | -0.7724673 | 0.0033307 | 0.0236653 |
####Build a Populus-only (Intraspecific) results table for ASVs with significant continuous GDD trends (padj < 0.05): pulls ASV IDs, joins full taxonomy from ps_populus, selects/renames key DESeq2 stats, keeps the first 47 rows, adds an ASV column, and renders a styled HTML table with kableExtra. ################################################################################
# Filter significant results (you can adjust the threshold for significance as
# needed)
significant_results_pop_cont_trend <- subset(results_gdd_trend_populus, padj < 0.05)
# Get ASV names of differentially abundant ASVs
significant_asv_names_pop_cont_trend <- rownames(significant_results_pop_cont_trend)
# Get the taxonomic information for the significant ASVs
significant_asv_tax_pop_cont_trend <- tax_table(ps_populus)[significant_asv_names_pop_cont_trend,
]
# Merge the results with taxonomic information
significant_results_table_pop_cont_trend <- cbind(significant_asv_tax_pop_cont_trend,
significant_results_pop_cont_trend)
# Select columns of interest for the final table
final_asv_table_pop_cont_trend <- significant_results_table_pop_cont_trend[, c("Kingdom",
"Phylum", "Class", "Order", "Family", "Genus", "Species", "log2FoldChange", "pvalue",
"padj")]
# Rename the columns for better presentation
colnames(final_asv_table_pop_cont_trend) <- c("Kingdom", "Phylum", "Class", "Order",
"Family", "Genus", "Species", "Log2 Fold Change", "P-value", "Adjusted P-value")
subset_final_asv_table_pop_cont_trend <- final_asv_table_pop_cont_trend[1:22, ]
# Get ASV names of differentially abundant ASVs
significant_asv_names_pop_cont_trend <- rownames(significant_results_pop_cont_trend)
# Add the ASV information to the table as the first column
final_asv_table_pop_cont_trend <- cbind(ASV = significant_asv_names_pop_cont_trend,
final_asv_table_pop_cont_trend)
# Display the final table
kable(subset_final_asv_table_pop_cont_trend, format = "html", align = "c") %>%
kable_styling(bootstrap_options = "striped", full_width = TRUE)
| Kingdom | Phylum | Class | Order | Family | Genus | Species | Log2.Fold.Change | P.value | Adjusted.P.value | |
|---|---|---|---|---|---|---|---|---|---|---|
| ASV22 | Bacteria | Proteobacteria | Gammaproteobacteria | Burkholderiales | Comamonadaceae | Pelomonas | NA | 3.0656600 | 0.0000000 | 0.0000000 |
| ASV40 | Bacteria | Proteobacteria | Alphaproteobacteria | Sphingomonadales | Sphingomonadaceae | Sphingomonas | NA | 1.3723249 | 0.0007929 | 0.0235705 |
| ASV41 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | Methylobacterium-Methylorubrum | NA | 1.1795006 | 0.0015860 | 0.0324135 |
| ASV46 | Bacteria | Proteobacteria | Alphaproteobacteria | Sphingomonadales | Sphingomonadaceae | Sphingomonas | NA | 1.4018055 | 0.0001169 | 0.0076485 |
| ASV58 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | Methylobacterium-Methylorubrum | NA | 1.1075945 | 0.0005533 | 0.0184728 |
| ASV62 | Bacteria | Proteobacteria | Gammaproteobacteria | Burkholderiales | Oxalobacteraceae | Massilia | NA | 1.1368271 | 0.0003852 | 0.0184728 |
| ASV69 | Bacteria | Proteobacteria | Gammaproteobacteria | Pseudomonadales | Moraxellaceae | Enhydrobacter | aerosaccus | 1.1184594 | 0.0005649 | 0.0184728 |
| ASV106 | Bacteria | Actinobacteriota | Actinobacteria | Frankiales | Geodermatophilaceae | Blastococcus | NA | -1.5514214 | 0.0000700 | 0.0076257 |
| ASV121 | Bacteria | Myxococcota | Myxococcia | Myxococcales | Myxococcaceae | P3OB-42 | NA | 1.4946363 | 0.0000133 | 0.0021770 |
| ASV140 | Bacteria | Proteobacteria | Gammaproteobacteria | Pseudomonadales | Pseudomonadaceae | Pseudomonas | NA | 1.4379687 | 0.0001026 | 0.0076485 |
| ASV143 | Bacteria | Myxococcota | Myxococcia | Myxococcales | Myxococcaceae | P3OB-42 | NA | 1.1398700 | 0.0012350 | 0.0318820 |
| ASV171 | Bacteria | Actinobacteriota | Actinobacteria | Kineosporiales | Kineosporiaceae | Pseudokineococcus | lusitanus | 1.0318601 | 0.0013063 | 0.0318820 |
| ASV175 | Bacteria | Actinobacteriota | Actinobacteria | Pseudonocardiales | Pseudonocardiaceae | Actinomycetospora | NA | 1.1833403 | 0.0005373 | 0.0184728 |
| ASV197 | Bacteria | Actinobacteriota | Actinobacteria | Kineosporiales | Kineosporiaceae | Kineococcus | NA | 1.0199813 | 0.0005173 | 0.0184728 |
| ASV218 | Bacteria | Bacteroidota | Bacteroidia | Cytophagales | Hymenobacteraceae | Hymenobacter | NA | 0.9378021 | 0.0024149 | 0.0430767 |
| ASV235 | Bacteria | Actinobacteriota | Actinobacteria | Propionibacteriales | Nocardioidaceae | Nocardioides | NA | -0.9182917 | 0.0020728 | 0.0398713 |
| ASV275 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Rhizobiaceae | Aureimonas | NA | 1.0388791 | 0.0013837 | 0.0318820 |
| ASV341 | Bacteria | Actinobacteriota | Actinobacteria | Pseudonocardiales | Pseudonocardiaceae | Pseudonocardia | NA | 0.8866996 | 0.0025212 | 0.0430767 |
| ASV342 | Bacteria | Proteobacteria | Alphaproteobacteria | Sphingomonadales | Sphingomonadaceae | Sphingomonas | NA | 0.9107848 | 0.0028299 | 0.0430767 |
| ASV365 | Bacteria | Actinobacteriota | Actinobacteria | Propionibacteriales | Nocardioidaceae | Nocardioides | alpinus | -0.8600979 | 0.0014625 | 0.0318820 |
| ASV377 | Bacteria | Bacteroidota | Bacteroidia | Cytophagales | Hymenobacteraceae | Hymenobacter | NA | 0.8629052 | 0.0028981 | 0.0430767 |
| ASV416 | Bacteria | Actinobacteriota | Actinobacteria | Propionibacteriales | Nocardioidaceae | Nocardioides | NA | -0.8239323 | 0.0026581 | 0.0430767 |
## FULL TABLE; NOT Subset (Populus):
kable(final_asv_table_pop_cont_trend, format = "html", align = "c") %>%
kable_styling(bootstrap_options = "striped", full_width = TRUE)
| ASV | Kingdom | Phylum | Class | Order | Family | Genus | Species | Log2.Fold.Change | P.value | Adjusted.P.value |
|---|---|---|---|---|---|---|---|---|---|---|
| ASV22 | Bacteria | Proteobacteria | Gammaproteobacteria | Burkholderiales | Comamonadaceae | Pelomonas | NA | 3.0656600 | 0.0000000 | 0.0000000 |
| ASV40 | Bacteria | Proteobacteria | Alphaproteobacteria | Sphingomonadales | Sphingomonadaceae | Sphingomonas | NA | 1.3723249 | 0.0007929 | 0.0235705 |
| ASV41 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | Methylobacterium-Methylorubrum | NA | 1.1795006 | 0.0015860 | 0.0324135 |
| ASV46 | Bacteria | Proteobacteria | Alphaproteobacteria | Sphingomonadales | Sphingomonadaceae | Sphingomonas | NA | 1.4018055 | 0.0001169 | 0.0076485 |
| ASV58 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | Methylobacterium-Methylorubrum | NA | 1.1075945 | 0.0005533 | 0.0184728 |
| ASV62 | Bacteria | Proteobacteria | Gammaproteobacteria | Burkholderiales | Oxalobacteraceae | Massilia | NA | 1.1368271 | 0.0003852 | 0.0184728 |
| ASV69 | Bacteria | Proteobacteria | Gammaproteobacteria | Pseudomonadales | Moraxellaceae | Enhydrobacter | aerosaccus | 1.1184594 | 0.0005649 | 0.0184728 |
| ASV106 | Bacteria | Actinobacteriota | Actinobacteria | Frankiales | Geodermatophilaceae | Blastococcus | NA | -1.5514214 | 0.0000700 | 0.0076257 |
| ASV121 | Bacteria | Myxococcota | Myxococcia | Myxococcales | Myxococcaceae | P3OB-42 | NA | 1.4946363 | 0.0000133 | 0.0021770 |
| ASV140 | Bacteria | Proteobacteria | Gammaproteobacteria | Pseudomonadales | Pseudomonadaceae | Pseudomonas | NA | 1.4379687 | 0.0001026 | 0.0076485 |
| ASV143 | Bacteria | Myxococcota | Myxococcia | Myxococcales | Myxococcaceae | P3OB-42 | NA | 1.1398700 | 0.0012350 | 0.0318820 |
| ASV171 | Bacteria | Actinobacteriota | Actinobacteria | Kineosporiales | Kineosporiaceae | Pseudokineococcus | lusitanus | 1.0318601 | 0.0013063 | 0.0318820 |
| ASV175 | Bacteria | Actinobacteriota | Actinobacteria | Pseudonocardiales | Pseudonocardiaceae | Actinomycetospora | NA | 1.1833403 | 0.0005373 | 0.0184728 |
| ASV197 | Bacteria | Actinobacteriota | Actinobacteria | Kineosporiales | Kineosporiaceae | Kineococcus | NA | 1.0199813 | 0.0005173 | 0.0184728 |
| ASV218 | Bacteria | Bacteroidota | Bacteroidia | Cytophagales | Hymenobacteraceae | Hymenobacter | NA | 0.9378021 | 0.0024149 | 0.0430767 |
| ASV235 | Bacteria | Actinobacteriota | Actinobacteria | Propionibacteriales | Nocardioidaceae | Nocardioides | NA | -0.9182917 | 0.0020728 | 0.0398713 |
| ASV275 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Rhizobiaceae | Aureimonas | NA | 1.0388791 | 0.0013837 | 0.0318820 |
| ASV341 | Bacteria | Actinobacteriota | Actinobacteria | Pseudonocardiales | Pseudonocardiaceae | Pseudonocardia | NA | 0.8866996 | 0.0025212 | 0.0430767 |
| ASV342 | Bacteria | Proteobacteria | Alphaproteobacteria | Sphingomonadales | Sphingomonadaceae | Sphingomonas | NA | 0.9107848 | 0.0028299 | 0.0430767 |
| ASV365 | Bacteria | Actinobacteriota | Actinobacteria | Propionibacteriales | Nocardioidaceae | Nocardioides | alpinus | -0.8600979 | 0.0014625 | 0.0318820 |
| ASV377 | Bacteria | Bacteroidota | Bacteroidia | Cytophagales | Hymenobacteraceae | Hymenobacter | NA | 0.8629052 | 0.0028981 | 0.0430767 |
| ASV416 | Bacteria | Actinobacteriota | Actinobacteria | Propionibacteriales | Nocardioidaceae | Nocardioides | NA | -0.8239323 | 0.0026581 | 0.0430767 |
# Export the table to a CSV file
write.csv(final_asv_table_spp_LMM, file = "final_asv_table_LMM.csv", row.names = FALSE)
write.csv(final_asv_table_spp_interaction, file = "final_asv_table_interaction.csv",
row.names = FALSE)
# Export the table to a tab-separated TXT file
write.table(final_asv_table_spp_LMM, file = "final_asv_table_LMM.txt", sep = "\t",
row.names = FALSE)
write.table(final_asv_table_spp_interaction, file = "final_asv_table_interaction.txt",
sep = "\t", row.names = FALSE)
write.csv(final_asv_table_bet_cont_trend, file = "final_asv_table_bet_cont_trend.csv",
row.names = FALSE)
write.csv(final_asv_table_pop_cont_trend, file = "final_asv_table_pop_cont_trend.csv",
row.names = FALSE)
# Export the table to a tab-separated TXT file
write.table(final_asv_table_bet_cont_trend, file = "final_asv_table_bet_cont_trend.txt",
sep = "\t", row.names = FALSE)
write.table(final_asv_table_pop_cont_trend, file = "final_asv_table_pop_cont_trend.csv.txt",
sep = "\t", row.names = FALSE)
####Build two quick Betula vs Populus comparison tables: pulls only the log2 fold-change (direction/magnitude) from the Species main-effect and from the SpeciesxGDD interaction results (no p-values or filtering), appends ASV IDs and full taxonomy, then shows the first 10 rows, so we can see which ASVs are higher in Betula vs Populus overall, and which ones’ GDD slopes differ by host. ################################################################################
#-------------------------------------------------------
## FOR `asv_scaled_noPlants_Phenology_stats_LMM` (i.e.,
## `asv_scaled_noPlants_Phen_filt_LMM`)
#-------------------------------------------------------
# To see differences b/w Populus and Betula
# Filter results for the 'Betula_populifolia vs Populus_tremuloides' comparison
results_betula_vs_populus_LMM <- results_species_diff_abund_LMM[, "log2FoldChange",
drop = FALSE]
results_betula_vs_populus_interaction <- results_interaction_diff_abund_LMM[, "log2FoldChange",
drop = FALSE]
# Add ASV names to the results
results_betula_vs_populus_LMM$ASV <- rownames(results_species_diff_abund_LMM)
results_betula_vs_populus_interaction$ASV <- rownames(results_interaction_diff_abund_LMM)
# Merge with taxonomic information
results_betula_vs_populus_LMM <- cbind(results_betula_vs_populus_LMM, tax_table(ps_phen_asv_LMM)[rownames(results_species_diff_abund_LMM),
])
results_betula_vs_populus_interaction <- cbind(results_betula_vs_populus_interaction,
tax_table(ps_phen_asv_LMM)[rownames(results_interaction_diff_abund_LMM), ])
# Select the columns of interest for the final table
final_table_betula_vs_populus_LMM <- results_betula_vs_populus_LMM[, c("ASV", "Kingdom",
"Phylum", "Class", "Order", "Family", "Genus", "Species", "log2FoldChange")]
final_table_betula_vs_populus_interaction <- results_betula_vs_populus_interaction[,
c("ASV", "Kingdom", "Phylum", "Class", "Order", "Family", "Genus", "Species",
"log2FoldChange")]
# Rename the columns for better presentation
colnames(final_table_betula_vs_populus_LMM) <- c("ASV", "Kingdom", "Phylum", "Class",
"Order", "Family", "Genus", "Species", "Log2 Fold Change")
colnames(final_table_betula_vs_populus_interaction) <- c("ASV", "Kingdom", "Phylum",
"Class", "Order", "Family", "Genus", "Species", "Log2 Fold Change")
subset_bet_vs_pop_LMM <- final_table_betula_vs_populus_LMM[1:10, ]
subset_bet_vs_pop_interaction <- final_table_betula_vs_populus_interaction[1:10,
]
# Display the final table
library(knitr)
kable(subset_bet_vs_pop_LMM, format = "html", align = "c") %>%
kable_styling(bootstrap_options = "striped", full_width = TRUE)
| ASV | Kingdom | Phylum | Class | Order | Family | Genus | Species | Log2.Fold.Change | |
|---|---|---|---|---|---|---|---|---|---|
| ASV7 | ASV7 | Bacteria | Proteobacteria | Alphaproteobacteria | Acetobacterales | Acetobacteraceae | Endobacter | NA | 0.3936066 |
| ASV8 | ASV8 | Bacteria | Proteobacteria | Alphaproteobacteria | Acetobacterales | Acetobacteraceae | Endobacter | NA | -3.7078117 |
| ASV9 | ASV9 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | 1174-901-12 | NA | 1.1452676 |
| ASV10 | ASV10 | Bacteria | Proteobacteria | NA | NA | NA | NA | NA | 6.2707595 |
| ASV12 | ASV12 | Bacteria | Firmicutes | Bacilli | Staphylococcales | Staphylococcaceae | Staphylococcus | NA | -0.5425867 |
| ASV13 | ASV13 | Bacteria | Firmicutes | Bacilli | Lactobacillales | Lactobacillaceae | Limosilactobacillus | NA | 0.0012678 |
| ASV14 | ASV14 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | 1174-901-12 | NA | 2.8943627 |
| ASV15 | ASV15 | Bacteria | Firmicutes | Bacilli | Bacillales | Bacillaceae | Bacillus | NA | 0.0012678 |
| ASV16 | ASV16 | Bacteria | Proteobacteria | Gammaproteobacteria | Enterobacterales | Enterobacteriaceae | Escherichia-Shigella | NA | -0.0795551 |
| ASV17 | ASV17 | Bacteria | Proteobacteria | Gammaproteobacteria | Burkholderiales | Oxalobacteraceae | Massilia | NA | -0.5037113 |
kable(subset_bet_vs_pop_interaction, format = "html", align = "c") %>%
kable_styling(bootstrap_options = "striped", full_width = TRUE)
| ASV | Kingdom | Phylum | Class | Order | Family | Genus | Species | Log2.Fold.Change | |
|---|---|---|---|---|---|---|---|---|---|
| ASV7 | ASV7 | Bacteria | Proteobacteria | Alphaproteobacteria | Acetobacterales | Acetobacteraceae | Endobacter | NA | -0.0042424 |
| ASV8 | ASV8 | Bacteria | Proteobacteria | Alphaproteobacteria | Acetobacterales | Acetobacteraceae | Endobacter | NA | -0.0058447 |
| ASV9 | ASV9 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | 1174-901-12 | NA | -0.0025876 |
| ASV10 | ASV10 | Bacteria | Proteobacteria | NA | NA | NA | NA | NA | -0.0010891 |
| ASV12 | ASV12 | Bacteria | Firmicutes | Bacilli | Staphylococcales | Staphylococcaceae | Staphylococcus | NA | 0.0011880 |
| ASV13 | ASV13 | Bacteria | Firmicutes | Bacilli | Lactobacillales | Lactobacillaceae | Limosilactobacillus | NA | 0.0000008 |
| ASV14 | ASV14 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | 1174-901-12 | NA | -0.0019100 |
| ASV15 | ASV15 | Bacteria | Firmicutes | Bacilli | Bacillales | Bacillaceae | Bacillus | NA | 0.0000008 |
| ASV16 | ASV16 | Bacteria | Proteobacteria | Gammaproteobacteria | Enterobacterales | Enterobacteriaceae | Escherichia-Shigella | NA | -0.0001356 |
| ASV17 | ASV17 | Bacteria | Proteobacteria | Gammaproteobacteria | Burkholderiales | Oxalobacteraceae | Massilia | NA | -0.0002825 |
####Create a Betula-only (Intraspecific) table of GDD trend effects: pulls just the log2 fold-change (no p-values) for each ASV from the continuous Betula model, adds ASV IDs and full taxonomy, and displays the first 10 rows as a styled HTML table to show direction/magnitude of change with GDD within Betula. ################################################################################
# Filter results
results_deseq_bet_cont_trend <- results_gdd_trend_betula[, "log2FoldChange", drop = FALSE]
# Add ASV names to the results
results_deseq_bet_cont_trend$ASV <- rownames(results_gdd_trend_betula)
# Merge with taxonomic information
results_deseq_bet_cont_trend <- cbind(results_deseq_bet_cont_trend, tax_table(ps_betula)[rownames(results_gdd_trend_betula),
])
# Select columns of interest for the final table
final_table_bet_cont_trend <- results_deseq_bet_cont_trend[, c("ASV", "Kingdom",
"Phylum", "Class", "Order", "Family", "Genus", "Species", "log2FoldChange")]
# Rename the columns for better presentation
colnames(final_table_bet_cont_trend) <- c("ASV", "Kingdom", "Phylum", "Class", "Order",
"Family", "Genus", "Species", "Log2 Fold Change")
subset_betula_deseq_cont_trend <- final_table_bet_cont_trend[1:10, ]
# Display the final table
library(knitr)
kable(subset_betula_deseq_cont_trend, format = "html", align = "c") %>%
kable_styling(bootstrap_options = "striped", full_width = TRUE)
| ASV | Kingdom | Phylum | Class | Order | Family | Genus | Species | Log2.Fold.Change | |
|---|---|---|---|---|---|---|---|---|---|
| ASV7 | ASV7 | Bacteria | Proteobacteria | Alphaproteobacteria | Acetobacterales | Acetobacteraceae | Endobacter | NA | 2.1242083 |
| ASV8 | ASV8 | Bacteria | Proteobacteria | Alphaproteobacteria | Acetobacterales | Acetobacteraceae | Endobacter | NA | 3.8385863 |
| ASV9 | ASV9 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | 1174-901-12 | NA | 2.0396728 |
| ASV10 | ASV10 | Bacteria | Proteobacteria | NA | NA | NA | NA | NA | 0.5050465 |
| ASV12 | ASV12 | Bacteria | Firmicutes | Bacilli | Staphylococcales | Staphylococcaceae | Staphylococcus | NA | -0.0079968 |
| ASV13 | ASV13 | Bacteria | Firmicutes | Bacilli | Lactobacillales | Lactobacillaceae | Limosilactobacillus | NA | 0.0000000 |
| ASV14 | ASV14 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | 1174-901-12 | NA | 1.8734110 |
| ASV15 | ASV15 | Bacteria | Firmicutes | Bacilli | Bacillales | Bacillaceae | Bacillus | NA | 0.0000000 |
| ASV16 | ASV16 | Bacteria | Proteobacteria | Gammaproteobacteria | Enterobacterales | Enterobacteriaceae | Escherichia-Shigella | NA | 0.0944411 |
| ASV17 | ASV17 | Bacteria | Proteobacteria | Gammaproteobacteria | Burkholderiales | Oxalobacteraceae | Massilia | NA | 3.4399251 |
####Create a Populus-only (Intraspecific) table of GDD trend effects: pulls just the log2 fold-change (no p-values) for each ASV from the continuous Populus model, adds ASV IDs and full taxonomy, and displays the first 10 rows as a styled HTML table to show direction/magnitude of change with GDD within Populus. ################################################################################
# Filter results
results_deseq_pop_cont_trend <- results_gdd_trend_populus[, "log2FoldChange", drop = FALSE]
# Add ASV names to the results
results_deseq_pop_cont_trend$ASV <- rownames(results_gdd_trend_populus)
# Merge with taxonomic information
results_deseq_pop_cont_trend <- cbind(results_deseq_pop_cont_trend, tax_table(ps_populus)[rownames(results_gdd_trend_populus),
])
# Select columns of interest for final table
final_table_pop_cont_trend <- results_deseq_pop_cont_trend[, c("ASV", "Kingdom",
"Phylum", "Class", "Order", "Family", "Genus", "Species", "log2FoldChange")]
# Rename the columns for better presentation
colnames(final_table_pop_cont_trend) <- c("ASV", "Kingdom", "Phylum", "Class", "Order",
"Family", "Genus", "Species", "Log2 Fold Change")
subset_populus_deseq_cont_trend <- final_table_pop_cont_trend[1:10, ]
# Display the final table
library(knitr)
kable(subset_populus_deseq_cont_trend, format = "html", align = "c") %>%
kable_styling(bootstrap_options = "striped", full_width = TRUE)
| ASV | Kingdom | Phylum | Class | Order | Family | Genus | Species | Log2.Fold.Change | |
|---|---|---|---|---|---|---|---|---|---|
| ASV7 | ASV7 | Bacteria | Proteobacteria | Alphaproteobacteria | Acetobacterales | Acetobacteraceae | Endobacter | NA | -0.8059764 |
| ASV8 | ASV8 | Bacteria | Proteobacteria | Alphaproteobacteria | Acetobacterales | Acetobacteraceae | Endobacter | NA | -0.2203953 |
| ASV9 | ASV9 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | 1174-901-12 | NA | 0.2463372 |
| ASV10 | ASV10 | Bacteria | Proteobacteria | NA | NA | NA | NA | NA | -0.2572925 |
| ASV12 | ASV12 | Bacteria | Firmicutes | Bacilli | Staphylococcales | Staphylococcaceae | Staphylococcus | NA | 0.8104871 |
| ASV13 | ASV13 | Bacteria | Firmicutes | Bacilli | Lactobacillales | Lactobacillaceae | Limosilactobacillus | NA | -0.0002296 |
| ASV14 | ASV14 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | 1174-901-12 | NA | 0.5500226 |
| ASV15 | ASV15 | Bacteria | Firmicutes | Bacilli | Bacillales | Bacillaceae | Bacillus | NA | -0.0002296 |
| ASV16 | ASV16 | Bacteria | Proteobacteria | Gammaproteobacteria | Enterobacterales | Enterobacteriaceae | Escherichia-Shigella | NA | -0.0002296 |
| ASV17 | ASV17 | Bacteria | Proteobacteria | Gammaproteobacteria | Burkholderiales | Oxalobacteraceae | Massilia | NA | 1.5207820 |
# Export the table to a CSV file
write.csv(final_table_betula_vs_populus_LMM, file = "final_table_betula_vs_populus_LMM.csv",
row.names = FALSE)
write.csv(final_table_betula_vs_populus_interaction, file = "final_table_betula_vs_populus_interaction.csv",
row.names = FALSE)
# Export the table to a tab-separated TXT file
write.table(final_table_betula_vs_populus_LMM, file = "final_table_betula_vs_populus_LMM.txt",
sep = "\t", row.names = FALSE)
write.table(final_table_betula_vs_populus_interaction, file = "final_table_betula_vs_populus_interaction.txt",
sep = "\t", row.names = FALSE)
# For GDD Trend:
# Export the table to a CSV file
write.csv(final_table_bet_cont_trend, file = "final_table_bet_cont_trend.csv", row.names = FALSE)
write.csv(final_table_pop_cont_trend, file = "final_table_pop_cont_trend.csv", row.names = FALSE)
# Export the table to a tab-separated TXT file
write.table(final_table_bet_cont_trend, file = "final_table_bet_cont_trend.txt",
sep = "\t", row.names = FALSE)
write.table(final_table_pop_cont_trend, file = "final_table_pop_cont_trend.txt",
sep = "\t", row.names = FALSE)
#——————————————————- ### DESeq2 PLOTTING #——————————————————-
####Filter Betula’s (INTRAspecific) continuous GDD results to
significant ASVs (significant_results_bet_cont_trend, padj
< 0.05), then actually build the BAR + BUBBLE plots from your earlier
final table final_asv_table_bet_cont_trend (which already
contains ASV IDs, taxonomy, and the renamed Log2.Fold.Change column).
################################################################################
############################################## Bar Plot
# Filter significant results
significant_results_bet_cont_trend <- subset(results_gdd_trend_betula, padj < 0.05)
# Create data frame with ASV names & log2 fold change values
data_for_barplot_bet_cont_trend <- as.data.frame(final_asv_table_bet_cont_trend)
# Sort data frame by log2 fold change in descending order
data_for_barplot_bet_cont_trend <- data_for_barplot_bet_cont_trend[order(-data_for_barplot_bet_cont_trend$Log2.Fold.Change),
]
library(forcats) # if you want to reorder Unknown last
# 1. Ensure Phylum/Genus is character
data_for_barplot_bet_cont_trend$Phylum <- as.character(data_for_barplot_bet_cont_trend$Phylum)
data_for_barplot_bet_cont_trend$Genus <- as.character(data_for_barplot_bet_cont_trend$Genus)
# 2. Replace true NAs with 'Unknown'
data_for_barplot_bet_cont_trend$Phylum[is.na(data_for_barplot_bet_cont_trend$Phylum)] <- "Unknown"
data_for_barplot_bet_cont_trend$Genus[is.na(data_for_barplot_bet_cont_trend$Genus)] <- "Unknown"
# 3. Convert to factor
data_for_barplot_bet_cont_trend$Phylum <- factor(data_for_barplot_bet_cont_trend$Phylum)
data_for_barplot_bet_cont_trend$Genus <- factor(data_for_barplot_bet_cont_trend$Genus)
# 4. Move 'Unknown' to end of legend
data_for_barplot_bet_cont_trend$Phylum <- fct_relevel(data_for_barplot_bet_cont_trend$Phylum,
"Unknown", after = Inf)
data_for_barplot_bet_cont_trend$Genus <- fct_relevel(data_for_barplot_bet_cont_trend$Genus,
"Unknown", after = Inf)
genus_colors <- c(Unknown = "darkgrey", `1174-901-12` = "brown", Actinomycetospora = "coral2",
Acidiphilium = "chocolate", Aureimonas = "orangered", Blastococcus = "orange",
Bryocella = "gold2", `Candidatus Ovatusbacter` = "lightgoldenrod3", Dietzia = "yellowgreen",
Endobacter = "olivedrab", Enhydrobacter = "darkseagreen", Frondihabitans = "palegreen",
Hymenobacter = "darkgreen", Kineococcus = "seagreen2", Klebsiella = "lightseagreen",
Massilia = "cyan2", `Methylobacterium-Methylorubrum` = "deepskyblue4", Methylocella = "blue",
Nocardioides = "darkslateblue", `P3OB-42` = "deepskyblue2", Pelomonas = "cadetblue3",
Pseudarthrobacter = "mediumpurple", Pseudokineococcus = "darkorchid", Pseudomonas = "orchid",
Pseudonocardia = "maroon3", Rothia = "magenta", Sphingomonas = "deeppink", Streptococcus = "lightcoral",
Terriglobus = "lightpink")
phylum_colors <- c(`NA` = "darkgrey", Unknown = "darkgrey", Proteobacteria = "darkorchid1",
Firmicutes = "turquoise3", Myxococcota = "deepskyblue2", Bacteroidota = "darkolivegreen3",
Bdellovibrionota = "yellow", Abditibacteriota = "brown", Acidobacteriota = "pink",
Actinobacteriota = "darkorange")
# Create Bar Plot (PHYLUM-level):
diff_abund_barplot_bet_cont_trend_phylum <- ggplot(data_for_barplot_bet_cont_trend, aes(x = ASV, y = Log2.Fold.Change, fill = Phylum)) +
geom_bar(stat = "identity", color = "black") +
labs(x = "ASV", y = "Log2 Fold Change") +
theme_minimal() +
theme(
axis.title.x = element_text(size = 8),
axis.title.y = element_text(size = 8),
axis.text.x = element_text(angle = -90, hjust = 1, size = 6),
axis.text.y = element_text(size = 6),
legend.title = element_text(size = 10),
legend.text = element_text(size = 10),
panel.border = element_rect(color = "black", size = 1, fill = NA),
# legend.position = "none",
axis.ticks = element_line(color = "black")
) +
scale_fill_manual(values = phylum_colors) +
guides(fill = guide_legend(keyheight = 0.75, keywidth = 0.75)) +
ggtitle(expression("Grey Birch"))
diff_abund_barplot_bet_cont_trend_phylum
#################################################################
# Bubble Plot (PHYLUM-level):
#################################################################
## --- Title strip stays the same ---
des_bet_title_bar <- ggplot() +
geom_rect(aes(xmin = 0.5, xmax = nrow(data_for_barplot_bet_cont_trend), ymin = 0.5, ymax = 0.75),
fill = "grey90", color = NA) +
geom_segment(aes(x = 0.5, xend = nrow(data_for_barplot_bet_cont_trend), y = 0.75, yend = 0.75), color = "black", linewidth = 0.6) +
geom_segment(aes(x = 0.5, xend = 0.5, y = 0.5, yend = 0.75), color = "black", linewidth = 0.6) +
geom_segment(aes(x = nrow(data_for_barplot_bet_cont_trend), xend = nrow(data_for_barplot_bet_cont_trend), y = 0.5, yend = 0.75), color = "black", linewidth = 0.6) +
annotate("text", x = nrow(data_for_barplot_bet_cont_trend)/2, y = 0.63,
label = "Grey Birch", size = 3.5, fontface = "bold") +
scale_x_continuous(expand = c(0, 0), limits = c(0.5, nrow(data_for_barplot_bet_cont_trend))) +
scale_y_continuous(limits = c(0.5, 1.1), expand = c(0, 0)) +
coord_cartesian(clip = "off") +
theme_void() +
theme(plot.margin = margin(0, 0.1, 0, 0.1, unit = "pt"))
## --- Bubble (circle point) version of DESeq2 plot ---
## keep x=ASV, y=Log2.Fold.Change, fill=Genus, border, fonts, legend, etc.
## (Ensure ASV is a factor so points line up on a discrete axis)
data_for_barplot_bet_cont_trend$ASV <- factor(data_for_barplot_bet_cont_trend$ASV, levels = data_for_barplot_bet_cont_trend$ASV)
diff_abund_bubble_bet_cont_trend_phylum <- ggplot(
data_for_barplot_bet_cont_trend,
aes(x = ASV, y = Log2.Fold.Change, fill = Phylum)
) +
geom_hline(yintercept = 0, linewidth = 0.4, color = "grey60") +
geom_point(aes(size = -log10(Adjusted.P.value)), shape = 21, stroke = 0.6, color = "black") + # bubble/circle points
# scale_size_continuous(
# name = expression(-log[10]("adj p")),
# range = c(2, 4), # make min larger & max bigger; preserves proportions
# guide = "none"
#) +
scale_x_discrete(expand = expansion(mult = c(0.04, 0.02))) +
scale_size_area(
name = expression(-log[10]("adj p")),
# max_size = 5,
limits = c(0, NA),
guide = "none"
) +
labs(x = "ASV", y = "Log2 Fold Change") +
theme_minimal() +
theme(
axis.title.x = element_text(size = 6),
axis.title.y = element_text(size = 6),
axis.text.x = element_text(angle = -90, vjust = 0.5, size = 6),
axis.text.y = element_text(size = 6),
legend.title = element_text(size = 6),
legend.text = element_text(size = 5),
legend.box.margin = margin(0, 0, 0, -12, unit = "pt"),
panel.border = element_rect(color = "black", size = 1, fill = NA),
axis.ticks = element_line(color = "black")
) +
scale_fill_manual(values = phylum_colors) +
guides(fill = guide_legend(override.aes = list(size = 2), keyheight = 0.5, keywidth = 0.5, ncol = 1))
## --- Combine as before with patchwork ---
bet_phy_diffabund_combined2 <- des_bet_title_bar / diff_abund_bubble_bet_cont_trend_phylum +
patchwork::plot_layout(heights = c(0.13, 1)) &
theme(plot.margin = margin(0, 0, 0, 0, unit = "pt"))
bet_phy_diffabund_combined2
################################################################
# Create the Bar Plot (Genus-level):
################################################################
des_bet_title_bar <- ggplot() +
geom_rect(aes(xmin = 0.5, xmax = nrow(data_for_barplot_bet_cont_trend), ymin = 0.5, ymax = 0.75),
fill = "grey90", color = NA) +
geom_segment(aes(x = 0.5, xend = nrow(data_for_barplot_bet_cont_trend), y = 0.75, yend = 0.75), color = "black", linewidth = 0.6) +
geom_segment(aes(x = 0.5, xend = 0.5, y = 0.5, yend = 0.75), color = "black", linewidth = 0.6) +
geom_segment(aes(x = nrow(data_for_barplot_bet_cont_trend), xend = nrow(data_for_barplot_bet_cont_trend), y = 0.5, yend = 0.75), color = "black", linewidth = 0.6) +
annotate("text", x = nrow(data_for_barplot_bet_cont_trend)/2, y = 0.63,
label = "Grey Birch", size = 3.5, fontface = "bold") +
scale_x_continuous(expand = c(0, 0), limits = c(0.5, nrow(data_for_barplot_bet_cont_trend))) +
scale_y_continuous(limits = c(0.5, 1.1), expand = c(0, 0)) +
coord_cartesian(clip = "off") +
theme_void() +
theme(plot.margin = margin(0, 0.1, 0, 0.1, unit = "pt"))
diff_abund_barplot_bet_cont_trend_genus <- ggplot(data_for_barplot_bet_cont_trend, aes(x = ASV, y = Log2.Fold.Change, fill = Genus)) +
geom_bar(stat = "identity", color = "black") +
# geom_text(aes(label = Genus), angle = 90, size = 2, vjust = -0.5) +
labs(x = "ASV", y = "Log2 Fold Change") +
theme_minimal() +
theme(
axis.title.x = element_text(size = 6),
axis.title.y = element_text(size = 6),
axis.text.x = element_text(angle = -90, vjust = 0.5, size = 5),
axis.text.y = element_text(size = 6),
legend.title = element_text(size = 6),
legend.text = element_text(size = 5),
legend.box.margin = margin(0, 0, 0, -12, unit = "pt"),
panel.border = element_rect(color = "black", size = 1, fill = NA),
# legend.position = "none",
axis.ticks = element_line(color = "black")
) +
guides(fill = guide_legend(ncol = 1, keyheight = 0.5, keywidth = 0.5)) +
scale_fill_manual(
values = genus_colors,
labels = function(x) {
x <- str_replace(x, "Methylobacterium-Methylorubrum", "Methylobacterium-\nMethylorubrum")
x <- str_replace(x, "Candidatus Ovatusbacter", "Candidatus\nOvatusbacter")
x
}
) #+
# ggtitle(expression("Grey Birch (" * italic("B. populifolia") * ")"))
bet_gen_diffabund_combined <- des_bet_title_bar / diff_abund_barplot_bet_cont_trend_genus +
plot_layout(heights = c(0.13, 1)) &
theme(plot.margin = margin(0, 0, 0, 0, unit = "pt"))
bet_gen_diffabund_combined
##################################################################
# Create Bubble Plot (GENUS-level):
##################################################################
## --- Title strip stays the same ---
des_bet_title_bar <- ggplot() +
geom_rect(aes(xmin = 0.5, xmax = nrow(data_for_barplot_bet_cont_trend), ymin = 0.5, ymax = 0.75),
fill = "grey90", color = NA) +
geom_segment(aes(x = 0.5, xend = nrow(data_for_barplot_bet_cont_trend), y = 0.75, yend = 0.75), color = "black", linewidth = 0.6) +
geom_segment(aes(x = 0.5, xend = 0.5, y = 0.5, yend = 0.75), color = "black", linewidth = 0.6) +
geom_segment(aes(x = nrow(data_for_barplot_bet_cont_trend), xend = nrow(data_for_barplot_bet_cont_trend), y = 0.5, yend = 0.75), color = "black", linewidth = 0.6) +
annotate("text", x = nrow(data_for_barplot_bet_cont_trend)/2, y = 0.63,
label = "Grey Birch", size = 3.5, fontface = "bold") +
scale_x_continuous(expand = c(0, 0), limits = c(0.5, nrow(data_for_barplot_bet_cont_trend))) +
scale_y_continuous(limits = c(0.5, 1.1), expand = c(0, 0)) +
coord_cartesian(clip = "off") +
theme_void() +
theme(plot.margin = margin(0, 0.1, 0, 0.1, unit = "pt"))
## --- Bubble (circle point) version of DESeq2 plot ---
## keep x=ASV, y=Log2.Fold.Change, fill=Genus, border, fonts, legend, etc.
## (Ensure ASV is a factor so points line up on a discrete axis)
data_for_barplot_bet_cont_trend$ASV <- factor(data_for_barplot_bet_cont_trend$ASV, levels = data_for_barplot_bet_cont_trend$ASV)
diff_abund_bubble_bet_cont_trend_genus <- ggplot(
data_for_barplot_bet_cont_trend,
aes(x = ASV, y = Log2.Fold.Change, fill = Genus)
) +
geom_hline(yintercept = 0, linewidth = 0.4, color = "grey60") +
geom_point(aes(size = -log10(Adjusted.P.value)), shape = 21, stroke = 0.6, color = "black") + # bubble/circle points
# scale_size_continuous(
# name = expression(-log[10]("adj p")),
# range = c(2, 4), # make min larger & max bigger; preserves proportions
# guide = "none"
#) +
scale_x_discrete(expand = expansion(mult = c(0.04, 0.02))) +
scale_size_area(
name = expression(-log[10]("adj p")),
max_size = 5,
limits = c(0, NA),
guide = "none"
) +
labs(x = "ASV", y = "Log2 Fold Change") +
theme_minimal() +
theme(
axis.title.x = element_text(size = 6),
axis.title.y = element_text(size = 6),
axis.text.x = element_text(angle = -90, vjust = 0.5, size = 5),
axis.text.y = element_text(size = 6),
legend.title = element_text(size = 6),
legend.text = element_text(size = 6),
legend.box.margin = margin(0, 0, 0, -12, unit = "pt"),
panel.border = element_rect(color = "black", size = 1, fill = NA),
axis.ticks = element_line(color = "black")
) +
scale_fill_manual(
values = genus_colors,
labels = function(x) {
x <- stringr::str_replace(x, "Methylobacterium-Methylorubrum",
"Methylobacterium-\nMethylorubrum")
x <- stringr::str_replace(x, "Candidatus Ovatusbacter",
"Candidatus\nOvatusbacter")
x
}
) +
guides(fill = guide_legend(override.aes = list(size = 2), keyheight = 0.5, keywidth = 0.5, ncol = 1))
## --- Combine as before with patchwork ---
bet_gen_diffabund_combined2 <- des_bet_title_bar / diff_abund_bubble_bet_cont_trend_genus +
patchwork::plot_layout(heights = c(0.13, 1)) &
theme(plot.margin = margin(0, 0, 0, 0, unit = "pt"))
bet_gen_diffabund_combined2
####Filter Populus’ (INTRAspecific) continuous GDD results to
significant ASVs (significant_results_pop_cont_trend, padj
< 0.05), then actually build the BAR + BUBBLE plots from your earlier
final table final_asv_table_pop_cont_trend (which already
contains ASV IDs, taxonomy, and the renamed Log2.Fold.Change column).
################################################################################
######################################################## Bar Plot
# Filter significant results
significant_results_pop_cont_trend <- subset(results_gdd_trend_populus, padj < 0.05)
# Create a data frame with ASV names and log2 fold change values
data_for_barplot_pop_cont_trend <- as.data.frame(final_asv_table_pop_cont_trend)
# Sort data frame by log2 fold change in descending order
data_for_barplot_pop_cont_trend <- data_for_barplot_pop_cont_trend[order(-data_for_barplot_pop_cont_trend$Log2.Fold.Change),
]
data_for_barplot_pop_cont_trend$Phylum <- ifelse(is.na(data_for_barplot_pop_cont_trend$Phylum),
"Unknown", data_for_barplot_pop_cont_trend$Phylum)
data_for_barplot_pop_cont_trend$Genus <- ifelse(is.na(data_for_barplot_pop_cont_trend$Genus),
"Unknown", data_for_barplot_pop_cont_trend$Genus)
genus_colors <- c(Unknown = "darkgrey", `1174-901-12` = "brown", Actinomycetospora = "coral2",
Acidiphilium = "chocolate", Aureimonas = "orangered", Blastococcus = "orange",
Bryocella = "gold2", `Candidatus Ovatusbacter` = "lightgoldenrod3", Dietzia = "yellowgreen",
Endobacter = "olivedrab", Enhydrobacter = "darkseagreen", Frondihabitans = "palegreen",
Hymenobacter = "darkgreen", Kineococcus = "seagreen2", Klebsiella = "lightseagreen",
Massilia = "cyan2", `Methylobacterium-Methylorubrum` = "deepskyblue4", Methylocella = "blue",
Nocardioides = "darkslateblue", `P3OB-42` = "deepskyblue2", Pelomonas = "cadetblue3",
Pseudarthrobacter = "mediumpurple", Pseudokineococcus = "darkorchid", Pseudomonas = "orchid",
Pseudonocardia = "maroon3", Rothia = "magenta", Sphingomonas = "deeppink", Streptococcus = "lightcoral",
Terriglobus = "lightpink")
phylum_colors <- c(`NA` = "darkgrey", Unknown = "darkgrey", Proteobacteria = "darkorchid1",
Firmicutes = "turquoise3", Myxococcota = "deepskyblue2", Bacteroidota = "darkolivegreen3",
Bdellovibrionota = "yellow", Abditibacteriota = "brown", Acidobacteriota = "pink",
Actinobacteriota = "darkorange")
############################################################
# Create Bar Plot (PHYLUM-level)
############################################################
#data_for_barplot_pop_cont_trend$AbsLog2FC <- abs(data_for_barplot_pop_cont_trend$Log2.Fold.Change)
#data_for_barplot_pop_cont_trend <- data_for_barplot_pop_cont_trend[order(-data_for_barplot_pop_cont_trend$AbsLog2FC), ]
#data_for_barplot_pop_cont_trend <- head(data_for_barplot_pop_cont_trend, 45)
diff_abund_barplot_pop_cont_trend_phylum <- ggplot(data_for_barplot_pop_cont_trend, aes(x = ASV, y = Log2.Fold.Change, fill = Phylum)) +
geom_bar(stat = "identity", color = "black") +
labs(x = "ASV", y = "Log2 Fold Change") +
theme_minimal() +
theme(
axis.title.x = element_text(size = 8),
axis.title.y = element_text(size = 8),
axis.text.x = element_text(angle = -90, hjust = 1, size = 6),
axis.text.y = element_text(size = 6),
legend.title = element_text(size = 10),
legend.text = element_text(size = 10),
panel.border = element_rect(color = "black", size = 1, fill = NA),
# legend.position = "none",
axis.ticks = element_line(color = "black")
) +
scale_fill_manual(values = phylum_colors) +
guides(fill = guide_legend(keyheight = 0.75, keywidth = 0.75)) +
ggtitle(expression("Trembling Aspen"))
diff_abund_barplot_pop_cont_trend_phylum
## --- Title strip stays the same ---
des_pop_title_bar <- ggplot() +
geom_rect(aes(xmin = 0.5, xmax = nrow(data_for_barplot_pop_cont_trend), ymin = 0.5, ymax = 0.75),
fill = "grey90", color = NA) +
geom_segment(aes(x = 0.5, xend = nrow(data_for_barplot_pop_cont_trend), y = 0.75, yend = 0.75), color = "black", linewidth = 0.6) +
geom_segment(aes(x = 0.5, xend = 0.5, y = 0.5, yend = 0.75), color = "black", linewidth = 0.6) +
geom_segment(aes(x = nrow(data_for_barplot_pop_cont_trend), xend = nrow(data_for_barplot_pop_cont_trend), y = 0.5, yend = 0.75), color = "black", linewidth = 0.6) +
annotate("text", x = nrow(data_for_barplot_pop_cont_trend)/2, y = 0.63,
label = "Trembling Aspen", size = 3.5, fontface = "bold") +
scale_x_continuous(expand = c(0, 0), limits = c(0.5, nrow(data_for_barplot_pop_cont_trend))) +
scale_y_continuous(limits = c(0.5, 1.1), expand = c(0, 0)) +
coord_cartesian(clip = "off") +
theme_void() +
theme(plot.margin = margin(0, 0.1, 0, 0.1, unit = "pt"))
####################################################################
## --- Bubble (circle point) version of DESeq2 plot ---
####################################################################
## keep x=ASV, y=Log2.Fold.Change, fill=Genus, border, fonts, legend, etc.
## (Ensure ASV is a factor so points line up on a discrete axis)
data_for_barplot_pop_cont_trend$ASV <- factor(data_for_barplot_pop_cont_trend$ASV, levels = data_for_barplot_pop_cont_trend$ASV)
diff_abund_bubble_pop_cont_trend_phylum <- ggplot(
data_for_barplot_pop_cont_trend,
aes(x = ASV, y = Log2.Fold.Change, fill = Phylum)
) +
geom_hline(yintercept = 0, linewidth = 0.4, color = "grey60") +
geom_point(aes(size = -log10(Adjusted.P.value)), shape = 21, stroke = 0.6, color = "black") + # bubble/circle points
# scale_size_continuous(
# name = expression(-log[10]("adj p")),
# range = c(2, 8), # make min larger & max bigger; preserves proportions
# guide = "none"
#) +
scale_x_discrete(expand = expansion(mult = c(0.04, 0.02))) +
scale_size_area(
name = expression(-log[10]("adj p")),
# max_size = 5,
limits = c(0, NA),
guide = "none"
) +
labs(x = "ASV", y = "Log2 Fold Change") +
theme_minimal() +
theme(
axis.title.x = element_text(size = 6),
axis.title.y = element_text(size = 6),
axis.text.x = element_text(angle = -90, vjust = 0.5, size = 6),
axis.text.y = element_text(size = 6),
legend.title = element_text(size = 6),
legend.text = element_text(size = 5),
legend.box.margin = margin(0, 0, 0, -12, unit = "pt"),
panel.border = element_rect(color = "black", size = 1, fill = NA),
axis.ticks = element_line(color = "black")
) +
scale_fill_manual(values = phylum_colors) +
guides(fill = guide_legend(override.aes = list(size = 2), keyheight = 0.5, keywidth = 0.5))
## --- Combine as before with patchwork ---
pop_phy_diffabund_combined2 <- des_pop_title_bar / diff_abund_bubble_pop_cont_trend_phylum +
patchwork::plot_layout(heights = c(0.13, 1)) &
theme(plot.margin = margin(0, 0, 0, 0, unit = "pt"))
pop_phy_diffabund_combined2
###############################################
# Create the bar plot (Genus-level):
###############################################
#data_for_barplot_pop_cont_trend$AbsLog2FC <- abs(data_for_barplot_pop_cont_trend$Log2.Fold.Change)
#data_for_barplot_pop_cont_trend <- data_for_barplot_pop_cont_trend[order(-data_for_barplot_pop_cont_trend$AbsLog2FC), ]
#data_for_barplot_pop_cont_trend <- head(data_for_barplot_pop_cont_trend, 45)
des_pop_title_bar <- ggplot() +
geom_rect(aes(xmin = 0.5, xmax = nrow(data_for_barplot_pop_cont_trend), ymin = 0.5, ymax = 0.75),
fill = "grey90", color = NA) +
geom_segment(aes(x = 0.5, xend = nrow(data_for_barplot_pop_cont_trend), y = 0.75, yend = 0.75), color = "black", linewidth = 0.6) +
geom_segment(aes(x = 0.5, xend = 0.5, y = 0.5, yend = 0.75), color = "black", linewidth = 0.6) +
geom_segment(aes(x = nrow(data_for_barplot_pop_cont_trend), xend = nrow(data_for_barplot_pop_cont_trend), y = 0.5, yend = 0.75), color = "black", linewidth = 0.6) +
annotate("text", x = nrow(data_for_barplot_pop_cont_trend)/2, y = 0.63,
label = "Trembling Aspen", size = 3.5, fontface = "bold") +
scale_x_continuous(expand = c(0, 0), limits = c(0.5, nrow(data_for_barplot_pop_cont_trend))) +
scale_y_continuous(limits = c(0.5, 1.1), expand = c(0, 0)) +
coord_cartesian(clip = "off") +
theme_void() +
theme(plot.margin = margin(0, 0.1, 0, 0.1, unit = "pt"))
diff_abund_barplot_pop_cont_trend_genus <- ggplot(data_for_barplot_pop_cont_trend, aes(x = ASV, y = Log2.Fold.Change, fill = Genus)) +
geom_bar(stat = "identity", color = "black") +
# geom_text(aes(label = Genus), angle = 90, size = 2, vjust = -0.5) +
labs(x = "ASV", y = "Log2 Fold Change") +
theme_minimal() +
theme(
axis.title.x = element_text(size = 6),
axis.title.y = element_text(size = 6),
axis.text.x = element_text(angle = -90, vjust = 0.5, size = 6),
axis.text.y = element_text(size = 6),
legend.title = element_text(size = 6),
legend.text = element_text(size = 5),
legend.box.margin = margin(0, 0, 0, -12, unit = "pt"),
panel.border = element_rect(color = "black", size = 1, fill = NA),
# legend.position = "none",
axis.ticks = element_line(color = "black")
) +
scale_fill_manual(
values = genus_colors,
labels = function(x) {
str_replace(x, "Methylobacterium-Methylorubrum", "Methylobacterium-\nMethylorubrum")
}
) +
guides(fill = guide_legend(keyheight = 0.5, keywidth = 0.5)) #+
# ggtitle(expression("Trembling Aspen (" * italic("P. tremuloides") * ")"))
pop_gen_diffabund_combined <- des_pop_title_bar / diff_abund_barplot_pop_cont_trend_genus +
plot_layout(heights = c(0.13, 1)) &
theme(plot.margin = margin(0, 0, 0, 0, unit = "pt"))
pop_gen_diffabund_combined
##############################################
# Create Bubble Plot (GENUS-level):
##############################################
## --- Title strip stays the same ---
des_pop_title_bar <- ggplot() +
geom_rect(aes(xmin = 0.5, xmax = nrow(data_for_barplot_pop_cont_trend), ymin = 0.5, ymax = 0.75),
fill = "grey90", color = NA) +
geom_segment(aes(x = 0.5, xend = nrow(data_for_barplot_pop_cont_trend), y = 0.75, yend = 0.75), color = "black", linewidth = 0.6) +
geom_segment(aes(x = 0.5, xend = 0.5, y = 0.5, yend = 0.75), color = "black", linewidth = 0.6) +
geom_segment(aes(x = nrow(data_for_barplot_pop_cont_trend), xend = nrow(data_for_barplot_pop_cont_trend), y = 0.5, yend = 0.75), color = "black", linewidth = 0.6) +
annotate("text", x = nrow(data_for_barplot_pop_cont_trend)/2, y = 0.63,
label = "Trembling Aspen", size = 3.5, fontface = "bold") +
scale_x_continuous(expand = c(0, 0), limits = c(0.5, nrow(data_for_barplot_pop_cont_trend))) +
scale_y_continuous(limits = c(0.5, 1.1), expand = c(0, 0)) +
coord_cartesian(clip = "off") +
theme_void() +
theme(plot.margin = margin(0, 0.1, 0, 0.1, unit = "pt"))
## --- Bubble (circle point) version of DESeq2 plot ---
## keep x=ASV, y=Log2.Fold.Change, fill=Genus, border, fonts, legend, etc.
## (Ensure ASV is a factor so points line up on a discrete axis)
data_for_barplot_pop_cont_trend$ASV <- factor(data_for_barplot_pop_cont_trend$ASV, levels = data_for_barplot_pop_cont_trend$ASV)
diff_abund_bubble_pop_cont_trend_genus <- ggplot(
data_for_barplot_pop_cont_trend,
aes(x = ASV, y = Log2.Fold.Change, fill = Genus)
) +
geom_hline(yintercept = 0, linewidth = 0.4, color = "grey60") +
geom_point(aes(size = -log10(Adjusted.P.value)), shape = 21, stroke = 0.6, color = "black") + # bubble/circle points
# scale_size_continuous(
# name = expression(-log[10]("adj p")),
# range = c(2, 8), # make min larger & max bigger; preserves proportions
# guide = "none"
#) +
scale_x_discrete(expand = expansion(mult = c(0.04, 0.02))) +
scale_size_area(
name = expression(-log[10]("adj p")),
max_size = 5,
limits = c(0, NA),
guide = "none"
) +
labs(x = "ASV", y = "Log2 Fold Change") +
theme_minimal() +
theme(
axis.title.x = element_text(size = 6),
axis.title.y = element_text(size = 6),
axis.text.x = element_text(angle = -90, vjust = 0.5, size = 6),
axis.text.y = element_text(size = 6),
legend.title = element_text(size = 6),
legend.text = element_text(size = 6),
legend.box.margin = margin(0, 0, 0, -12, unit = "pt"),
panel.border = element_rect(color = "black", size = 1, fill = NA),
axis.ticks = element_line(color = "black")
) +
scale_fill_manual(
values = genus_colors,
labels = function(x) {
stringr::str_replace(x, "Methylobacterium-Methylorubrum", "Methylobacterium-\nMethylorubrum")
}
) +
guides(fill = guide_legend(override.aes = list(size = 2), keyheight = 0.5, keywidth = 0.5))
## --- Combine as before with patchwork ---
pop_gen_diffabund_combined2 <- des_pop_title_bar / diff_abund_bubble_pop_cont_trend_genus +
patchwork::plot_layout(heights = c(0.13, 1)) &
theme(plot.margin = margin(0, 0, 0, 0, unit = "pt"))
pop_gen_diffabund_combined2
library(gridExtra)
library(grid)
# Arrange the plots in a grid with labels
## PHYLUM:
deseq_phylum_combined_cont_trend <- arrangeGrob(
grobs = list(
arrangeGrob(diff_abund_barplot_bet_cont_trend_phylum, top = textGrob("a", x = unit(0, "npc"), y = unit(1, "npc"), just = c("left", "top"), gp = gpar(fontsize = 30, fontface = "bold"))),
arrangeGrob(diff_abund_barplot_pop_cont_trend_phylum, top = textGrob("b", x = unit(0, "npc"), y = unit(1, "npc"), just = c("left", "top"), gp = gpar(fontsize = 30, fontface = "bold")))
),
ncol = 1,
nrow = 2
)
# Save
ggsave("deseq_phylum_combined_cont_trend.png", deseq_phylum_combined_cont_trend, width = 7, height = 7)
ggsave("deseq_phylum_combined_cont_trend.pdf", deseq_phylum_combined_cont_trend, width = 7, height = 7)
## As ".TIFF" File!!
ggsave(
filename = "deseq_phylum_combined_cont_trend.tiff",
plot = deseq_phylum_combined_cont_trend,
width = 7,
height = 7,
units = "in",
dpi = 600, # high resolution for publication
compression = "lzw" # prevents giant file sizes
)
## GENUS:
deseq_genus_combined_cont_trend <- arrangeGrob(
grobs = list(
arrangeGrob(diff_abund_barplot_bet_cont_trend_genus, top = textGrob("a", x = unit(0, "npc"), y = unit(1, "npc"), just = c("left", "top"), gp = gpar(fontsize = 30, fontface = "bold"))),
arrangeGrob(diff_abund_barplot_pop_cont_trend_genus, top = textGrob("b", x = unit(0, "npc"), y = unit(1, "npc"), just = c("left", "top"), gp = gpar(fontsize = 30, fontface = "bold")))
),
ncol = 1,
nrow = 2
)
# Save
ggsave("deseq_genus_combined_cont_trend.png", deseq_genus_combined_cont_trend, width = 7, height = 7)
ggsave("deseq_genus_combined_cont_trend.pdf", deseq_genus_combined_cont_trend, width = 7, height = 7)
## As ".TIFF" File!!
ggsave(
filename = "deseq_genus_combined_cont_trend.tiff",
plot = deseq_genus_combined_cont_trend,
width = 7,
height = 7,
units = "in",
dpi = 600, # high resolution for publication
compression = "lzw" # prevents giant file sizes
)
## FOR BUBBLE PLOTS (PHYLUM-LEVEL)!!!
library(gridExtra)
library(grid)
# Arrange the plots in a grid with labels
## PHYLUM:
deseq_phylum_combined_cont_trend2 <- arrangeGrob(
grobs = list(
arrangeGrob(bet_phy_diffabund_combined2, top = textGrob("A", x = unit(0, "npc"), y = unit(1, "npc"), just = c("left", "top"), gp = gpar(fontsize = 30, fontface = "bold"))),
arrangeGrob(pop_phy_diffabund_combined2, top = textGrob("B", x = unit(0, "npc"), y = unit(1, "npc"), just = c("left", "top"), gp = gpar(fontsize = 30, fontface = "bold")))
),
ncol = 1,
nrow = 2
)
# Save
ggsave("deseq_phylum_combined_cont_trend2.png", deseq_phylum_combined_cont_trend2, width = 7, height = 7)
ggsave("deseq_phylum_combined_cont_trend2.pdf", deseq_phylum_combined_cont_trend2, width = 7, height = 7)
## As ".TIFF" File!!
ggsave(
filename = "deseq_phylum_combined_cont_trend2.tiff",
plot = deseq_phylum_combined_cont_trend2,
width = 7,
height = 7,
units = "in",
dpi = 600, # high resolution for publication
compression = "lzw" # prevents giant file sizes
)
# Arrange/combine plots into 2 panels
deseq_phylum_combined_cont_trend2 <- arrangeGrob(diff_abund_barplot_bet_cont_trend_phylum,
diff_abund_barplot_pop_cont_trend_phylum, ncol = 2, nrow = 1)
deseq_genus_combined_cont_trend2 <- arrangeGrob(diff_abund_barplot_bet_cont_trend_genus,
diff_abund_barplot_pop_cont_trend_genus, ncol = 2, nrow = 1)
# Save the combined plot
ggsave("deseq_phylum_combined_cont_trend2.png", deseq_phylum_combined_cont_trend2,
width = 7.5, height = 5, dpi = 600)
ggsave("deseq_genus_combined_cont_trend2.png", deseq_genus_combined_cont_trend2,
width = 7.5, height = 5, dpi = 600)
# As PDF
ggsave("deseq_phylum_combined_cont_trend2.pdf", plot = deseq_phylum_combined_cont_trend2,
width = 7.5, height = 5, dpi = 600)
ggsave("deseq_genus_combined_cont_trend2.pdf", plot = deseq_genus_combined_cont_trend2,
width = 7.5, height = 5, dpi = 600)
final_asv_table_spp_LMM and
final_asv_table_spp_interaction to visualize ASV log2
fold-changes by Genus with custom colors. (Re)computes significant sets
(significant_results_spp_LMM, ..._interaction,
padj < 0.05) but the plots actually use the prebuilt tables
final_asv_table_spp_LMM and
final_asv_table_spp_interaction (which already contain ASV,
Genus, and Log2.Fold.Change).#-------------------------------------------------------
## FOR `asv_scaled_noPlants_Phenology_stats_LMM` (i.e.,
## `asv_scaled_noPlants_Phen_filt_LMM`)
#-------------------------------------------------------
######################################################## Bar Plot
# Filter significant results (you can adjust the threshold for significance as
# needed)
significant_results_spp_LMM <- subset(results_species_diff_abund_LMM, padj < 0.05)
# significant_results_spp_LMM <- subset(results_species_diff_abund_LMM)
significant_results_spp_interaction <- subset(results_interaction_diff_abund_LMM,
padj < 0.05)
# significant_results_spp_interaction <-
# subset(results_interaction_diff_abund_LMM)
# Create a data frame with ASV names and log2 fold change values
data_for_barplot_LMM <- as.data.frame(final_asv_table_spp_LMM)
data_for_barplot_interaction <- as.data.frame(final_asv_table_spp_interaction)
# Sort the data frame by log2 fold change in descending order
# data_for_barplot_LMM <-
# data_for_barplot_LMM[order(-data_for_barplot_LMM$Log2FoldChange), ]
# data_for_barplot_interaction <-
# data_for_barplot_interaction[order(-data_for_barplot_interaction$Log2FoldChange),
# ]
genus_colors <- c(`NA` = "darkgrey", Unknown = "darkgrey", Spirosoma = "maroon3",
Sphingomonas = "magenta", Terriglobus = "hotpink", Rubellimicrobium = "mediumpurple1",
Pseudomonocardia = "plum", Quadrisphaera = "lightslateblue", PMMR1 = "darkslateblue",
`P3OB-42` = "lightseagreen", Nocardioides = "cyan", Nakamurella = "springgreen",
Methylocella = "steelblue", `Methylobacterium-Methylorubrum` = "deepskyblue",
Lawsonella = "khaki1", Massilia = "paleturquoise", Klenkia = "dodgerblue", Micrococcus = "blue2",
Marisediminicola = "darkblue", Hymenobacter = "seagreen3", Klebsiella = "yellow",
Ellin6055 = "darkgreen", Endobacter = "olivedrab", Corynebacterium = "darksalmon",
Belnapia = "olivedrab2", Dermacoccus = "green", Blastococcus = "lightgoldenrod3",
Bryocella = "navajowhite2", Alteribacillus = "gold", Acidiphilium = "orange",
Actinomycetospora = "chocolate", `1174-901-12` = "brown", Abditibacterium = "coral2",
Amnibacterium = "lightpink")
phylum_colors <- c(`NA` = "darkgrey", Unknown = "darkgrey", Proteobacteria = "darkorchid1",
Firmicutes = "turquoise3", Myxococcota = "deepskyblue2", Bacteroidota = "darkolivegreen3",
Bdellovibrionota = "yellow", Abditibacteriota = "brown", Acidobacteriota = "pink",
Actinobacteriota = "darkorange")
# Create the bar plot
diff_abund_barplot_genus <- ggplot(data_for_barplot_LMM, aes(x = ASV, y = Log2.Fold.Change,
fill = Genus)) + geom_bar(stat = "identity", color = "black") + labs(x = "ASV",
y = "Log2 Fold Change") + theme_minimal() + theme(axis.title.x = element_text(size = 9),
axis.title.y = element_text(size = 9), axis.text.x = element_text(angle = 45,
hjust = 1, size = 8), axis.text.y = element_text(size = 8), legend.title = element_text(size = 9),
legend.text = element_text(size = 8), panel.border = element_rect(color = "black",
size = 1, fill = NA), axis.ticks = element_line(color = "black")) + theme(axis.text.x = element_text(angle = 45,
hjust = 1)) + scale_fill_manual(values = genus_colors) + ggtitle("ONLY Between Species (Betula vs. Populus)")
diff_abund_barplot_genus
############################
diff_abund_interaction_barplot <- ggplot(data_for_barplot_interaction, aes(x = ASV,
y = Log2.Fold.Change, fill = Genus)) + geom_bar(stat = "identity", color = "black") +
labs(x = "ASV", y = "Log2 Fold Change") + theme_minimal() + theme(axis.title.x = element_text(size = 9),
axis.title.y = element_text(size = 9), axis.text.x = element_text(angle = 45,
hjust = 1, size = 8), axis.text.y = element_text(size = 8), legend.title = element_text(size = 9),
legend.text = element_text(size = 8), panel.border = element_rect(color = "black",
size = 1, fill = NA), axis.ticks = element_line(color = "black")) + theme(axis.text.x = element_text(angle = 45,
hjust = 1)) + scale_fill_manual(values = genus_colors) + ggtitle("Between Betula & Populus when INTERACTING with GDD")
diff_abund_interaction_barplot
#-------------------------------------------------------------------------------
# Bubble Plot (GENUS)
#-------------------------------------------------------------------------------
data_for_barplot_LMM$ASV <- factor(
data_for_barplot_LMM$ASV,
levels = data_for_barplot_LMM$ASV
)
# Create the bubble plot
diff_abund_bubble_genus_sp <- ggplot(
data_for_barplot_LMM,
aes(
x = fct_reorder(ASV, Log2.Fold.Change, .fun = ~median(., na.rm = TRUE), .desc = TRUE),
y = Log2.Fold.Change,
fill = Genus
)
) +
geom_hline(yintercept = 0, linewidth = 0.4, color = "grey60") +
geom_point(aes(size = -log10(Adjusted.P.value)), shape = 21, stroke = 0.6, color = "black") + # bubble/circle points
# scale_size_continuous(
# name = expression(-log[10]("adj p")),
# range = c(2, 8), # make min larger & max bigger; preserves proportions
# guide = "none"
#) +
scale_x_discrete(expand = expansion(mult = c(0.04, 0.02))) +
scale_size_area(
name = expression(-log[10]("adj p")),
# max_size = 5,
limits = c(0, NA),
guide = "none"
) +
labs(x = "ASV", y = "Log2 Fold Change") +
theme_minimal() +
theme(
axis.title.x = element_text(size = 6),
axis.title.y = element_text(size = 6),
axis.text.x = element_text(angle = -90, vjust = 0.5, size = 6),
axis.text.y = element_text(size = 6),
legend.title = element_text(size = 6),
legend.text = element_text(size = 5),
legend.box.margin = margin(0, 0, 0, -12, unit = "pt"),
panel.border = element_rect(color = "black", size = 1, fill = NA),
axis.ticks = element_line(color = "black")
) +
scale_fill_manual(
values = genus_colors,
labels = function(x) {
stringr::str_replace(x, "Methylobacterium-Methylorubrum", "Methylobacterium-\nMethylorubrum")
}
) +
guides(fill = guide_legend(override.aes = list(size = 2), keyheight = 0.5, keywidth = 0.5))
diff_abund_bubble_genus_sp
# Save the plot as a PNG file (you can change the file extension and parameters
# accordingly)
ggsave("diff_abund_barplot_genus.jpg", plot = diff_abund_barplot_genus, width = 7,
height = 4.85, units = "in", dpi = 600)
ggsave("diff_abund_interaction_barplot.pdf", plot = diff_abund_interaction_barplot,
width = 12, height = 8, units = "in")
############################################# Create the bar plot (Phylum!)
diff_abund_barplot_phylum <- ggplot(data_for_barplot_LMM, aes(x = ASV, y = Log2.Fold.Change,
fill = Phylum)) + geom_bar(stat = "identity", color = "black") + labs(x = "ASV",
y = "Log2 Fold Change") + theme_minimal() + theme(axis.title.x = element_text(size = 9),
axis.title.y = element_text(size = 9), axis.text.x = element_text(angle = 45,
hjust = 1, size = 8), axis.text.y = element_text(size = 8), legend.title = element_text(size = 9),
legend.text = element_text(size = 8), panel.border = element_rect(color = "black",
size = 1, fill = NA), axis.ticks = element_line(color = "black"), aspect.ratio = 0.75) +
scale_fill_manual(values = phylum_colors)
diff_abund_barplot_phylum
# Interaction:
diff_abund_barplot_phylum_interact <- ggplot(data_for_barplot_interaction, aes(x = ASV,
y = Log2.Fold.Change, fill = Phylum)) + geom_bar(stat = "identity", color = "black") +
labs(x = "ASV", y = "Log2 Fold Change") + theme_minimal() + theme(axis.title.x = element_text(size = 9),
axis.title.y = element_text(size = 9), axis.text.x = element_text(angle = 45,
hjust = 1, size = 8), axis.text.y = element_text(size = 8), legend.title = element_text(size = 9),
legend.text = element_text(size = 8), panel.border = element_rect(color = "black",
size = 1, fill = NA), axis.ticks = element_line(color = "black"), aspect.ratio = 0.75) +
scale_fill_manual(values = phylum_colors)
diff_abund_barplot_phylum_interact
# Save the plot as a PNG file (you can change the file extension and parameters
# accordingly)
ggsave("diff_abund_barplot_phylum.pdf", plot = diff_abund_barplot_phylum, width = 12,
height = 8, units = "in")
ggsave("diff_abund_barplot_phylum_interact.pdf", plot = diff_abund_barplot_phylum_interact,
width = 12, height = 8, units = "in")
#-------------------------------------------------------------------------------
# Bubble Plot (GENUS)
#-------------------------------------------------------------------------------
data_for_barplot_LMM$ASV <- factor(
data_for_barplot_LMM$ASV,
levels = data_for_barplot_LMM$ASV
)
# Create the bubble plot
diff_abund_bubble_phylum_sp <- ggplot(
data_for_barplot_LMM,
aes(
x = fct_reorder(ASV, Log2.Fold.Change, .fun = ~median(., na.rm = TRUE), .desc = TRUE),
y = Log2.Fold.Change,
fill = Phylum
)
) +
geom_hline(yintercept = 0, linewidth = 0.4, color = "grey60") +
geom_point(aes(size = -log10(Adjusted.P.value)), shape = 21, stroke = 0.6, color = "black") + # bubble/circle points
# scale_size_continuous(
# name = expression(-log[10]("adj p")),
# range = c(2, 8), # make min larger & max bigger; preserves proportions
# guide = "none"
#) +
scale_x_discrete(expand = expansion(mult = c(0.04, 0.02))) +
scale_size_area(
name = expression(-log[10]("adj p")),
# max_size = 5,
limits = c(0, NA),
guide = "none"
) +
labs(x = "ASV", y = "Log2 Fold Change") +
theme_minimal() +
theme(
axis.title.x = element_text(size = 6),
axis.title.y = element_text(size = 6),
axis.text.x = element_text(angle = -90, vjust = 0.5, size = 6),
axis.text.y = element_text(size = 6),
legend.title = element_text(size = 6),
legend.text = element_text(size = 5),
legend.box.margin = margin(0, 0, 0, -12, unit = "pt"),
panel.border = element_rect(color = "black", size = 1, fill = NA),
axis.ticks = element_line(color = "black")
) +
scale_fill_manual(values = phylum_colors) +
guides(fill = guide_legend(override.aes = list(size = 2), keyheight = 0.5, keywidth = 0.5))
diff_abund_bubble_phylum_sp
# Arrange the plots in a grid
deseq_combined_gen_phy <- arrangeGrob(diff_abund_barplot_phylum, diff_abund_barplot_genus,
ncol = 1, nrow = 2)
# Save the combined plot
ggsave("deseq_combined_gen_phy.jpg", deseq_combined_gen_phy, width = 7, height = 7.7)
#################### Bubble Plot:
# Arrange the plots in a grid
deseq_combined_gen_phy_bubble <- arrangeGrob(grobs = list(arrangeGrob(diff_abund_bubble_phylum_sp,
top = textGrob("A", x = unit(0, "npc"), y = unit(1, "npc"), just = c("left",
"top"), gp = gpar(fontsize = 30, fontface = "bold"))), arrangeGrob(diff_abund_bubble_genus_sp,
top = textGrob("B", x = unit(0, "npc"), y = unit(1, "npc"), just = c("left",
"top"), gp = gpar(fontsize = 30, fontface = "bold")))), ncol = 1, nrow = 2)
# Save the combined plot
ggsave("deseq_combined_gen_phy_bubble.tiff", deseq_combined_gen_phy_bubble, width = 7,
height = 7.5, units = "in", dpi = 600, compression = "lzw", device = "tiff")
ggsave("deseq_combined_gen_phy_bubble.png", deseq_combined_gen_phy_bubble, width = 7,
height = 7.5, units = "in", dpi = 600)
ggsave("deseq_combined_gen_phy_bubble.pdf", deseq_combined_gen_phy_bubble, width = 7,
height = 7.5, units = "in", dpi = 600)
genus_colors <- c(Unknown = "darkgrey", Spirosoma = "deeppink", Sphingomonas = "maroon3",
Staphylococcus = "magenta", Terriglobus = "hotpink", Rubellimicrobium = "mediumpurple1",
Pseudomonocardia = "plum", Quadrisphaera = "lightslateblue", PMMR1 = "darkslateblue",
`P3OB-42` = "lightseagreen", Nocardioides = "slateblue", Nakamurella = "springgreen",
Methylocella = "steelblue", `Methylobacterium-Methylorubrum` = "deepskyblue",
Caenimonas = "cadetblue3", Aeromicrobium = "royalblue3", Lawsonella = "khaki2",
Massilia = "cyan", Klenkia = "cadetblue", Enhydrobacter = "cornflowerblue", Marmoricola = "skyblue4",
Micrococcus = "blue2", Marisediminicola = "darkblue", Hymenobacter = "seagreen3",
Klebsiella = "yellow", Frondihabitans = "aquamarine2", Ellin4375 = "darkgreen",
Ellin6055 = "palegreen", Endobacter = "olivedrab", Brachybacterium = "burlywood",
Bacteroides = "yellowgreen", Corynebacterium = "darksalmon", Belnapia = "olivedrab2",
Dermacoccus = "green", Blastococcus = "lightgoldenrod3", Paracoccus = "lightpink4",
Bryocella = "navajowhite2", Alteribacillus = "gold2", Acidiphilium = "orange",
Actinomycetospora = "chocolate", Haemophilus = "firebrick2", Actinoallomurus = "orangered",
`1174-901-12` = "brown", Abditibacterium = "coral2", Rhizobacter = "chocolate4",
Amnibacterium = "lightpink", Streptococcus = "darkmagenta", Oryzihumus = "thistle3",
Novosphingobium = "mediumaquamarine", `Pedococcus-Phycicoccus` = "slateblue4",
Blautia = "orchid", Haliea = "yellow3", Granulicella = "sienna1", Pseudomonas = "dodgerblue4",
Chryseobacterium = "lightpink3", Psychroglaciecola = "darkorchid4", Curtobacterium = "darkgoldenrod",
Brevundimonas = "darkseagreen", Pseudokineococcus = "turquoise3", Aureimonas = "darkslategrey",
Kocuria = "lightblue", Gaiella = "rosybrown", Hansschlegelia = "lightgoldenrod",
Devosia = "slateblue", Williamsia = "yellow4", Qipengyuania = "maroon4", Dietzia = "seagreen",
Pseudarthrobacter = "firebrick3", Rothia = "purple", Kineococcus = "deepskyblue4",
Pseudonocardia = "deeppink4", `Candidatus Ovatusbacter` = "tan4")
# eval = FALSE
#-------------------------------------------------------------------------------
## GDD 437
#-------------------------------------------------------------------------------
# Get differential abundance results for tree species
results_diff_abund_LMM_437 <- results(dds_437, contrast = c("Species", "Betula_populifolia",
"Populus_tremuloides"))
# Filter significant ASVs for species comparison significant_asvs_LMM_437 <-
# subset(results_diff_abund_LMM_437, padj < 0.05)
significant_asvs_LMM_437 <- subset(results_diff_abund_LMM_437)
head(significant_asvs_LMM_437)
## log2 fold change (MLE): Species Betula_populifolia vs Populus_tremuloides
## Wald test p-value: Species Betula_populifolia vs Populus_tremuloides
## DataFrame with 6 rows and 6 columns
## baseMean log2FoldChange lfcSE stat pvalue padj
## <numeric> <numeric> <numeric> <numeric> <numeric> <numeric>
## ASV7 24.9 5.60879e+00 1.487489 3.77064e+00 1.62827e-04 0.1396243
## ASV8 2.2 -1.76553e+00 1.030519 -1.71325e+00 8.66674e-02 1.0000000
## ASV9 19.1 3.35547e+00 1.515721 2.21378e+00 NA NA
## ASV10 27.0 4.70043e+00 1.106808 4.24684e+00 2.16811e-05 0.0371831
## ASV12 16.7 6.13815e-01 0.875288 7.01272e-01 4.83133e-01 1.0000000
## ASV13 1.0 -2.04163e-16 0.953588 -2.14100e-16 1.00000e+00 1.0000000
#-------------------------------------------------------------------------------
# ASV Heatmap:
#-------------------------------------------------------------------------------
# Assuming 'dds' is your DESeq2 object and 'top_asvs' is the data frame
# containing top ASVs
top_asv_names_LMM_437 <- rownames(significant_asvs_LMM_437)
top_asv_counts_LMM_437 <- counts(dds_437)[top_asv_names_LMM_437, ]
# Create the heatmap
heatmap(as.matrix(top_asv_counts_LMM_437), scale = "row", Rowv = FALSE, Colv = FALSE,
col = viridis::viridis(100))
#-------------------------------------------------------------------------------
# Top ASVs for Species:
#-------------------------------------------------------------------------------
# Select the columns you want in the table
top_asv_table_spp_LMM_437 <- significant_asvs_LMM_437[, c("baseMean", "log2FoldChange",
"lfcSE", "stat", "pvalue", "padj")]
# Optionally, you can add the taxonomic information if available Assuming you
# have a taxonomic table named 'tax_table' with a column 'Genus'
top_asv_table_spp_LMM_437$Genus <- taxa_rdp[rownames(top_asv_table_spp_LMM_437),
"Genus"]
# Print the table
print(top_asv_table_spp_LMM_437)
## log2 fold change (MLE): Species Betula_populifolia vs Populus_tremuloides
## Wald test p-value: Species Betula_populifolia vs Populus_tremuloides
## DataFrame with 1732 rows and 7 columns
## baseMean log2FoldChange lfcSE stat pvalue padj
## <numeric> <numeric> <numeric> <numeric> <numeric> <numeric>
## ASV7 24.9 5.608792 1.487489 3.770643 1.62827e-04 0.1396243
## ASV8 2.2 -1.765533 1.030519 -1.713246 8.66674e-02 1.0000000
## ASV9 19.1 3.355467 1.515721 2.213777 NA NA
## ASV10 27.0 4.700431 1.106808 4.246836 2.16811e-05 0.0371831
## ASV12 16.7 0.613815 0.875288 0.701272 4.83133e-01 1.0000000
## ... ... ... ... ... ... ...
## ASV1786 1 -2.04163e-16 0.953588 -2.141e-16 1 1
## ASV1787 1 -2.04163e-16 0.953588 -2.141e-16 1 1
## ASV1788 1 -2.04163e-16 0.953588 -2.141e-16 1 1
## ASV1789 1 -2.04163e-16 0.953588 -2.141e-16 1 1
## ASV1790 1 -2.04163e-16 0.953588 -2.141e-16 1 1
## Genus
## <character>
## ASV7 Endobacter
## ASV8 Endobacter
## ASV9 1174-901-12
## ASV10 NA
## ASV12 Staphylococcus
## ... ...
## ASV1786 NA
## ASV1787 Conexibacter
## ASV1788 Methylobacterium-Met..
## ASV1789 NA
## ASV1790 NA
head(top_asv_table_spp_LMM_437)
## log2 fold change (MLE): Species Betula_populifolia vs Populus_tremuloides
## Wald test p-value: Species Betula_populifolia vs Populus_tremuloides
## DataFrame with 6 rows and 7 columns
## baseMean log2FoldChange lfcSE stat pvalue padj
## <numeric> <numeric> <numeric> <numeric> <numeric> <numeric>
## ASV7 24.9 5.60879e+00 1.487489 3.77064e+00 1.62827e-04 0.1396243
## ASV8 2.2 -1.76553e+00 1.030519 -1.71325e+00 8.66674e-02 1.0000000
## ASV9 19.1 3.35547e+00 1.515721 2.21378e+00 NA NA
## ASV10 27.0 4.70043e+00 1.106808 4.24684e+00 2.16811e-05 0.0371831
## ASV12 16.7 6.13815e-01 0.875288 7.01272e-01 4.83133e-01 1.0000000
## ASV13 1.0 -2.04163e-16 0.953588 -2.14100e-16 1.00000e+00 1.0000000
## Genus
## <character>
## ASV7 Endobacter
## ASV8 Endobacter
## ASV9 1174-901-12
## ASV10 NA
## ASV12 Staphylococcus
## ASV13 Limosilactobacillus
# Export the table to a CSV file
write.csv(top_asv_table_spp_LMM_437, file = "top_asv_table_LMM_437.csv", row.names = FALSE)
#-------------------------------------------------------------------------------
# Making Kable Table
#-------------------------------------------------------------------------------
# Filter significant results (you can adjust the threshold for significance as
# needed)
significant_results_spp_LMM_437 <- subset(results_diff_abund_LMM_437, padj < 0.05)
# significant_results_spp_LMM_437 <- subset(results_diff_abund_LMM_437, padj)
# Get ASV names of differentially abundant ASVs
significant_asv_names_spp_LMM_437 <- rownames(significant_results_spp_LMM_437)
# Get the taxonomic information for the significant ASVs
significant_asv_tax_spp_LMM_437 <- tax_table(ps_phen_asv_LMM)[significant_asv_names_spp_LMM_437,
]
# Merge the results with taxonomic information
significant_results_table_spp_LMM_437 <- cbind(significant_asv_tax_spp_LMM_437, significant_results_spp_LMM_437)
# Select columns of interest for the final table
final_asv_table_spp_LMM_437 <- significant_results_table_spp_LMM_437[, c("Kingdom",
"Phylum", "Class", "Order", "Family", "Genus", "Species", "log2FoldChange", "pvalue",
"padj")]
# Rename the columns for better presentation
colnames(final_asv_table_spp_LMM_437) <- c("Kingdom", "Phylum", "Class", "Order",
"Family", "Genus", "Species", "Log2 Fold Change", "P-value", "Adjusted P-value")
subset_final_asv_table_LMM_437 <- final_asv_table_spp_LMM_437[1, ]
# Get ASV names of differentially abundant ASVs
significant_asv_names_spp_LMM_437 <- rownames(significant_results_spp_LMM_437)
# Add the ASV information to the table as the first column
final_asv_table_spp_LMM_437 <- cbind(ASV = significant_asv_names_spp_LMM_437, final_asv_table_spp_LMM_437)
# Display the final table
kable(subset_final_asv_table_LMM_437, format = "html", align = "c") %>%
kable_styling(bootstrap_options = "striped", full_width = TRUE)
| Kingdom | Phylum | Class | Order | Family | Genus | Species | Log2.Fold.Change | P.value | Adjusted.P.value | |
|---|---|---|---|---|---|---|---|---|---|---|
| ASV10 | Bacteria | Proteobacteria | NA | NA | NA | NA | NA | 4.700431 | 2.17e-05 | 0.0371831 |
# Export the table to a CSV file
write.csv(final_asv_table_spp_LMM_437, file = "final_asv_table_spp_LMM_437.csv",
row.names = FALSE)
# Export the table to a tab-separated TXT file
write.table(final_asv_table_spp_LMM_437, file = "final_asv_table_spp_LMM_437.txt",
sep = "\t", row.names = FALSE)
#-------------------------------------------------------------------------------
# To see differences b/w Populus and Betula
#-------------------------------------------------------------------------------
# Filter results for the 'Betula_populifolia vs Populus_tremuloides' comparison
results_betula_vs_populus_LMM_437 <- results_diff_abund_LMM_437[, "log2FoldChange",
drop = FALSE]
# Add ASV names to the results
results_betula_vs_populus_LMM_437$ASV <- rownames(results_diff_abund_LMM_437)
# Merge with taxonomic information
results_betula_vs_populus_LMM_437 <- cbind(results_betula_vs_populus_LMM_437, tax_table(ps_phen_asv_LMM)[rownames(results_diff_abund_LMM_437),
])
# Select the columns of interest for the final table
final_table_betula_vs_populus_LMM_437 <- results_betula_vs_populus_LMM_437[, c("ASV",
"Kingdom", "Phylum", "Class", "Order", "Family", "Genus", "Species", "log2FoldChange")]
# Rename the columns for better presentation
colnames(final_table_betula_vs_populus_LMM_437) <- c("ASV", "Kingdom", "Phylum",
"Class", "Order", "Family", "Genus", "Species", "Log2 Fold Change")
subset_bet_vs_pop_LMM_437 <- final_table_betula_vs_populus_LMM_437[1:10, ]
# Display the final table
library(knitr)
kable(subset_bet_vs_pop_LMM_437, format = "html", align = "c") %>%
kable_styling(bootstrap_options = "striped", full_width = TRUE)
| ASV | Kingdom | Phylum | Class | Order | Family | Genus | Species | Log2.Fold.Change | |
|---|---|---|---|---|---|---|---|---|---|
| ASV7 | ASV7 | Bacteria | Proteobacteria | Alphaproteobacteria | Acetobacterales | Acetobacteraceae | Endobacter | NA | 5.6087918 |
| ASV8 | ASV8 | Bacteria | Proteobacteria | Alphaproteobacteria | Acetobacterales | Acetobacteraceae | Endobacter | NA | -1.7655329 |
| ASV9 | ASV9 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | 1174-901-12 | NA | 3.3554673 |
| ASV10 | ASV10 | Bacteria | Proteobacteria | NA | NA | NA | NA | NA | 4.7004310 |
| ASV12 | ASV12 | Bacteria | Firmicutes | Bacilli | Staphylococcales | Staphylococcaceae | Staphylococcus | NA | 0.6138153 |
| ASV13 | ASV13 | Bacteria | Firmicutes | Bacilli | Lactobacillales | Lactobacillaceae | Limosilactobacillus | NA | 0.0000000 |
| ASV14 | ASV14 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | 1174-901-12 | NA | 4.3784994 |
| ASV15 | ASV15 | Bacteria | Firmicutes | Bacilli | Bacillales | Bacillaceae | Bacillus | NA | 0.0000000 |
| ASV16 | ASV16 | Bacteria | Proteobacteria | Gammaproteobacteria | Enterobacterales | Enterobacteriaceae | Escherichia-Shigella | NA | 0.0000000 |
| ASV17 | ASV17 | Bacteria | Proteobacteria | Gammaproteobacteria | Burkholderiales | Oxalobacteraceae | Massilia | NA | 0.0000000 |
# Export the table to a CSV file
write.csv(final_table_betula_vs_populus_LMM_437, file = "final_table_betula_vs_populus_LMM_437.csv",
row.names = FALSE)
# Export the table to a tab-separated TXT file
write.table(final_table_betula_vs_populus_LMM_437, file = "final_table_betula_vs_populus_LMM_437.txt",
sep = "\t", row.names = FALSE)
#-------------------------------------------------------------------------------
# Bar Plot
#-------------------------------------------------------------------------------
# Filter significant results (you can adjust the threshold for significance as
# needed)
significant_results_spp_LMM_437 <- subset(results_diff_abund_LMM_437, padj < 0.05)
# significant_results_spp_LMM_437 <- subset(results_diff_abund_LMM_437)
# Create a data frame with ASV names and log2 fold change values
data_for_barplot_LMM_437 <- data.frame(ASV = rownames(significant_results_spp_LMM_437),
Log2FoldChange = significant_results_spp_LMM_437$log2FoldChange)
data_for_barplot_437 <- as.data.frame(final_asv_table_spp_LMM_437)
data_for_barplot_437$Genus <- ifelse(is.na(data_for_barplot_437$Genus), "Unknown",
data_for_barplot_437$Genus)
# Add a new column for the absolute values of Log2FoldChange
data_for_barplot_LMM_437$AbsLog2FoldChange <- abs(data_for_barplot_LMM_437$Log2FoldChange)
# Sort the data frame by the absolute values of Log2FoldChange in descending
# order
data_for_barplot_LMM_437 <- data_for_barplot_LMM_437[order(-data_for_barplot_LMM_437$AbsLog2FoldChange),
]
# Select the top 100 ASVs for the bar plot
data_for_barplot_LMM_437 <- data_for_barplot_LMM_437[1:25, ]
data_for_barplot_LMM_437 <- na.omit(data_for_barplot_LMM_437)
# Create the bar plot
deseq_plot437_genus <- ggplot(data_for_barplot_437, aes(x = ASV, y = Log2.Fold.Change,
fill = Genus)) + geom_bar(stat = "identity", color = "black", width = 0.25) +
labs(x = "ASV", y = "Log2 Fold Change") + theme_minimal() + theme(axis.title.x = element_text(size = 8),
axis.title.y = element_text(size = 8), axis.text.x = element_text(angle = -90,
hjust = 1, size = 6), axis.text.y = element_text(size = 6), legend.title = element_text(size = 12),
legend.text = element_text(size = 12), panel.border = element_rect(color = "black",
size = 1, fill = NA), legend.position = "none", axis.ticks = element_line(color = "black")) +
scale_fill_manual(values = genus_colors)
deseq_plot437_genus
ggsave("deseq_plot437_genus.png", deseq_plot437_genus, width = 12, height = 8)
#-------------------------------------------------------------------------------
# Bubble Plot
#-------------------------------------------------------------------------------
data_for_barplot_437$ASV <- factor(
data_for_barplot_437$ASV,
levels = data_for_barplot_437$ASV
)
# Create the bubble plot
deseq_plot437_genus2 <- ggplot(
data_for_barplot_437,
aes(x = ASV, y = Log2.Fold.Change, fill = Genus)
) +
geom_hline(yintercept = 0, linewidth = 0.4, color = "grey60") +
geom_point(aes(size = -log10(Adjusted.P.value)), shape = 21, stroke = 0.6, color = "black") + # bubble/circle points
# scale_x_discrete(expand = expansion(mult = c(0.04, 0.02))) +
scale_size_area(
name = expression(-log[10]("adj p")),
max_size = 5,
limits = c(0, NA),
guide = "none"
) +
labs(x = "ASV", y = "Log2 Fold Change") +
theme_minimal() +
theme(
axis.title.x = element_text(size = 6),
axis.title.y = element_text(size = 6),
axis.text.x = element_text(angle = -90, vjust = 0.5, size = 6),
axis.text.y = element_text(size = 6),
legend.title = element_text(size = 6),
legend.text = element_text(size = 5),
legend.box.margin = margin(0, 0, 0, -12, unit = "pt"),
panel.border = element_rect(color = "black", size = 1, fill = NA),
axis.ticks = element_line(color = "black"),
legend.position = "none"
) +
# guides(fill = guide_legend(keyheight = 0.5, keywidth = 0.5)) +
scale_fill_manual(values = genus_colors)
deseq_plot437_genus2
deseq_plot437_phylum <- ggplot(data_for_barplot_437, aes(x = ASV, y = Log2.Fold.Change, fill = Phylum)) +
geom_bar(stat = "identity", color = "black", width = 0.25) +
labs(x = "ASV", y = "Log2 Fold Change") +
theme_minimal() +
theme(
axis.title.x = element_text(size = 8),
axis.title.y = element_text(size = 8),
axis.text.x = element_text(angle = -90, hjust = 1, size = 6),
axis.text.y = element_text(size = 6),
legend.title = element_text(size = 12),
legend.text = element_text(size = 12),
panel.border = element_rect(color = "black", size = 1, fill = NA),
legend.position = "none",
axis.ticks = element_line(color = "black")
) +
scale_fill_manual(values = phylum_colors)
deseq_plot437_phylum
#ggsave("deseq_plot437_phylum.png", deseq_plot437_phylum, width=12, height=8)
#-------------------------------------------------------------------------------
# Bubble Plot
#-------------------------------------------------------------------------------
# Create the bubble plot
deseq_plot437_phylum2 <- ggplot(
data_for_barplot_437,
aes(x = ASV, y = Log2.Fold.Change, fill = Phylum)
) +
geom_hline(yintercept = 0, linewidth = 0.4, color = "grey60") +
geom_point(aes(size = -log10(Adjusted.P.value)), shape = 21, stroke = 0.6, color = "black") + # bubble/circle points
scale_size_continuous(
name = expression(-log[10]("adj p")),
# range = c(2, 4), # make min larger & max bigger; preserves proportions
guide = "none"
) +
labs(x = "ASV", y = "Log2 Fold Change") +
theme_minimal() +
theme(
axis.title.x = element_text(size = 6),
axis.title.y = element_text(size = 6),
axis.text.x = element_text(angle = -90, vjust = 0.5, size = 6),
axis.text.y = element_text(size = 6),
legend.title = element_text(size = 6),
legend.text = element_text(size = 5),
legend.box.margin = margin(0, 0, 0, -12, unit = "pt"),
panel.border = element_rect(color = "black", size = 1, fill = NA),
axis.ticks = element_line(color = "black")
) +
guides(fill = guide_legend(keyheight = 0.5, keywidth = 0.5)) +
scale_fill_manual(values = phylum_colors)
deseq_plot437_phylum2
#-------------------------------------------------------------------------------
## GDD 605
#-------------------------------------------------------------------------------
# Get differential abundance results for tree species
results_diff_abund_LMM_605 <- results(dds_605, contrast=c("Species", "Betula_populifolia", "Populus_tremuloides"))
# Filter significant ASVs for species comparison
#significant_asvs_LMM_605 <- subset(results_diff_abund_LMM_605, padj < 0.05)
significant_asvs_LMM_605 <- subset(results_diff_abund_LMM_605)
head(significant_asvs_LMM_605)
## log2 fold change (MLE): Species Betula_populifolia vs Populus_tremuloides
## Wald test p-value: Species Betula_populifolia vs Populus_tremuloides
## DataFrame with 6 rows and 6 columns
## baseMean log2FoldChange lfcSE stat pvalue padj
## <numeric> <numeric> <numeric> <numeric> <numeric> <numeric>
## ASV7 9.8 -7.21285e-01 1.404122 -5.13691e-01 NA NA
## ASV8 3.0 -2.32192e+00 1.201822 -1.93200e+00 5.33590e-02 1.04946e-01
## ASV9 2.0 -1.58496e+00 1.042405 -1.52048e+00 1.28389e-01 NA
## ASV10 102.7 7.67525e+00 0.766104 1.00185e+01 1.26346e-23 9.34962e-22
## ASV12 11.9 2.18638e-01 0.962748 2.27098e-01 8.20347e-01 8.47007e-01
## ASV13 1.0 -1.99084e-16 0.942237 -2.11289e-16 1.00000e+00 NA
#-------------------------------------------------------------------------------
#ASV Heatmap:
#-------------------------------------------------------------------------------
# Assuming 'dds' is your DESeq2 object and 'top_asvs' is the data frame containing top ASVs
top_asv_names_LMM_605 <- rownames(significant_asvs_LMM_605)
top_asv_counts_LMM_605 <- counts(dds_437)[top_asv_names_LMM_605, ]
# Create the heatmap
heatmap(as.matrix(top_asv_counts_LMM_605), scale = "row", Rowv = FALSE, Colv = FALSE, col = viridis::viridis(100))
#-------------------------------------------------------------------------------
# Top ASVs for Species:
#-------------------------------------------------------------------------------
# Select the columns you want in the table
top_asv_table_spp_LMM_605 <- significant_asvs_LMM_605[, c("baseMean", "log2FoldChange", "lfcSE", "stat", "pvalue", "padj")]
# Optionally, you can add the taxonomic information if available
# Assuming you have a taxonomic table named 'tax_table' with a column 'Genus'
top_asv_table_spp_LMM_605$Genus <- taxa_rdp[rownames(top_asv_table_spp_LMM_605), "Genus"]
# Print the table
print(top_asv_table_spp_LMM_605)
## log2 fold change (MLE): Species Betula_populifolia vs Populus_tremuloides
## Wald test p-value: Species Betula_populifolia vs Populus_tremuloides
## DataFrame with 1732 rows and 7 columns
## baseMean log2FoldChange lfcSE stat pvalue padj
## <numeric> <numeric> <numeric> <numeric> <numeric> <numeric>
## ASV7 9.8 -0.721285 1.404122 -0.513691 NA NA
## ASV8 3.0 -2.321925 1.201822 -1.932004 5.33590e-02 1.04946e-01
## ASV9 2.0 -1.584961 1.042405 -1.520484 1.28389e-01 NA
## ASV10 102.7 7.675246 0.766104 10.018547 1.26346e-23 9.34962e-22
## ASV12 11.9 0.218638 0.962748 0.227098 8.20347e-01 8.47007e-01
## ... ... ... ... ... ... ...
## ASV1786 1.2 -4.85426e-01 0.902373 -5.37944e-01 0.590615 NA
## ASV1787 1.0 -1.99084e-16 0.942237 -2.11289e-16 1.000000 NA
## ASV1788 1.0 -1.99084e-16 0.942237 -2.11289e-16 1.000000 NA
## ASV1789 1.0 -1.99084e-16 0.942237 -2.11289e-16 1.000000 NA
## ASV1790 1.0 -1.99084e-16 0.942237 -2.11289e-16 1.000000 NA
## Genus
## <character>
## ASV7 Endobacter
## ASV8 Endobacter
## ASV9 1174-901-12
## ASV10 NA
## ASV12 Staphylococcus
## ... ...
## ASV1786 NA
## ASV1787 Conexibacter
## ASV1788 Methylobacterium-Met..
## ASV1789 NA
## ASV1790 NA
head(top_asv_table_spp_LMM_605)
## log2 fold change (MLE): Species Betula_populifolia vs Populus_tremuloides
## Wald test p-value: Species Betula_populifolia vs Populus_tremuloides
## DataFrame with 6 rows and 7 columns
## baseMean log2FoldChange lfcSE stat pvalue padj
## <numeric> <numeric> <numeric> <numeric> <numeric> <numeric>
## ASV7 9.8 -7.21285e-01 1.404122 -5.13691e-01 NA NA
## ASV8 3.0 -2.32192e+00 1.201822 -1.93200e+00 5.33590e-02 1.04946e-01
## ASV9 2.0 -1.58496e+00 1.042405 -1.52048e+00 1.28389e-01 NA
## ASV10 102.7 7.67525e+00 0.766104 1.00185e+01 1.26346e-23 9.34962e-22
## ASV12 11.9 2.18638e-01 0.962748 2.27098e-01 8.20347e-01 8.47007e-01
## ASV13 1.0 -1.99084e-16 0.942237 -2.11289e-16 1.00000e+00 NA
## Genus
## <character>
## ASV7 Endobacter
## ASV8 Endobacter
## ASV9 1174-901-12
## ASV10 NA
## ASV12 Staphylococcus
## ASV13 Limosilactobacillus
# Export the table to a CSV file
write.csv(top_asv_table_spp_LMM_605, file = "top_asv_table_LMM_605.csv", row.names = FALSE)
#-------------------------------------------------------------------------------
# Making Kable Table
#-------------------------------------------------------------------------------
# Filter significant results (you can adjust the threshold for significance as needed)
significant_results_spp_LMM_605 <- subset(results_diff_abund_LMM_605, padj < 0.05)
#significant_results_spp_LMM_605 <- subset(results_diff_abund_LMM_605)
# Get ASV names of differentially abundant ASVs
significant_asv_names_spp_LMM_605 <- rownames(significant_results_spp_LMM_605)
# Get the taxonomic information for the significant ASVs
significant_asv_tax_spp_LMM_605 <- tax_table(ps_phen_asv_LMM)[significant_asv_names_spp_LMM_605, ]
# Merge the results with taxonomic information
significant_results_table_spp_LMM_605 <- cbind(significant_asv_tax_spp_LMM_605, significant_results_spp_LMM_605)
# Select columns of interest for the final table
final_asv_table_spp_LMM_605 <- significant_results_table_spp_LMM_605[, c("Kingdom", "Phylum", "Class", "Order", "Family", "Genus", "Species", "log2FoldChange", "pvalue", "padj")]
# Rename the columns for better presentation
colnames(final_asv_table_spp_LMM_605) <- c("Kingdom", "Phylum", "Class", "Order", "Family", "Genus", "Species", "Log2 Fold Change", "P-value", "Adjusted P-value")
subset_final_asv_table_LMM_605 <- final_asv_table_spp_LMM_605[1:10, ]
# Get ASV names of differentially abundant ASVs
significant_asv_names_spp_LMM_605 <- rownames(significant_results_spp_LMM_605)
# Add the ASV information to the table as the first column
final_asv_table_spp_LMM_605 <- cbind(ASV = significant_asv_names_spp_LMM_605, final_asv_table_spp_LMM_605)
# Display the final table
kable(subset_final_asv_table_LMM_605, format = "html", align = "c") %>%
kable_styling(bootstrap_options = "striped", full_width = TRUE)
| Kingdom | Phylum | Class | Order | Family | Genus | Species | Log2.Fold.Change | P.value | Adjusted.P.value | |
|---|---|---|---|---|---|---|---|---|---|---|
| ASV10 | Bacteria | Proteobacteria | NA | NA | NA | NA | NA | 7.675246 | 0.0000000 | 0.0000000 |
| ASV14 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | 1174-901-12 | NA | 3.263029 | 0.0031319 | 0.0239463 |
| ASV19 | Bacteria | Proteobacteria | NA | NA | NA | NA | NA | 5.263024 | 0.0000092 | 0.0002279 |
| ASV32 | Bacteria | Proteobacteria | Alphaproteobacteria | Sphingomonadales | Sphingomonadaceae | Sphingomonas | NA | -3.963467 | 0.0032360 | 0.0239463 |
| ASV33 | Bacteria | Actinobacteriota | Actinobacteria | Kineosporiales | Kineosporiaceae | Quadrisphaera | NA | -5.145672 | 0.0000013 | 0.0000489 |
| ASV43 | Bacteria | Firmicutes | Bacilli | Bacillales | Marinococcaceae | Alteribacillus | NA | 3.070384 | 0.0069143 | 0.0393583 |
| ASV44 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | Methylobacterium-Methylorubrum | NA | -4.277978 | 0.0003805 | 0.0056318 |
| ASV45 | Bacteria | Actinobacteriota | Actinobacteria | Pseudonocardiales | Pseudonocardiaceae | Actinomycetospora | iriomotensis | -3.807350 | 0.0008216 | 0.0101329 |
| ASV54 | Bacteria | Proteobacteria | Alphaproteobacteria | Sphingomonadales | Sphingomonadaceae | Sphingomonas | NA | -4.498244 | 0.0002484 | 0.0045955 |
| ASV59 | Bacteria | NA | NA | NA | NA | NA | NA | -4.643847 | 0.0010062 | 0.0106369 |
# Export the table to a CSV file
write.csv(final_asv_table_spp_LMM_605, file = "final_asv_table_spp_LMM_605.csv", row.names = FALSE)
# Export the table to a tab-separated TXT file
write.table(final_asv_table_spp_LMM_605, file = "final_asv_table_spp_LMM_605.txt", sep = "\t", row.names = FALSE)
#-------------------------------------------------------------------------------
#To see differences b/w Populus and Betula
#-------------------------------------------------------------------------------
# Filter results for the "Betula_populifolia vs Populus_tremuloides" comparison
results_betula_vs_populus_LMM_605 <- results_diff_abund_LMM_605[, "log2FoldChange", drop = FALSE]
# Add ASV names to the results
results_betula_vs_populus_LMM_605$ASV <- rownames(results_diff_abund_LMM_605)
# Merge with taxonomic information
results_betula_vs_populus_LMM_605 <- cbind(results_betula_vs_populus_LMM_605, tax_table(ps_phen_asv_LMM)[rownames(results_diff_abund_LMM_605), ])
# Select the columns of interest for the final table
final_table_betula_vs_populus_LMM_605 <- results_betula_vs_populus_LMM_605[, c("ASV", "Kingdom", "Phylum", "Class", "Order", "Family", "Genus", "Species", "log2FoldChange")]
# Rename the columns for better presentation
colnames(final_table_betula_vs_populus_LMM_605) <- c("ASV", "Kingdom", "Phylum", "Class", "Order", "Family", "Genus", "Species", "Log2 Fold Change")
subset_bet_vs_pop_LMM_605 <- final_table_betula_vs_populus_LMM_605[1:10, ]
# Display the final table
library(knitr)
kable(subset_bet_vs_pop_LMM_605, format = "html", align = "c") %>%
kable_styling(bootstrap_options = "striped", full_width = TRUE)
| ASV | Kingdom | Phylum | Class | Order | Family | Genus | Species | Log2.Fold.Change | |
|---|---|---|---|---|---|---|---|---|---|
| ASV7 | ASV7 | Bacteria | Proteobacteria | Alphaproteobacteria | Acetobacterales | Acetobacteraceae | Endobacter | NA | -0.7212855 |
| ASV8 | ASV8 | Bacteria | Proteobacteria | Alphaproteobacteria | Acetobacterales | Acetobacteraceae | Endobacter | NA | -2.3219247 |
| ASV9 | ASV9 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | 1174-901-12 | NA | -1.5849608 |
| ASV10 | ASV10 | Bacteria | Proteobacteria | NA | NA | NA | NA | NA | 7.6752462 |
| ASV12 | ASV12 | Bacteria | Firmicutes | Bacilli | Staphylococcales | Staphylococcaceae | Staphylococcus | NA | 0.2186384 |
| ASV13 | ASV13 | Bacteria | Firmicutes | Bacilli | Lactobacillales | Lactobacillaceae | Limosilactobacillus | NA | 0.0000000 |
| ASV14 | ASV14 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | 1174-901-12 | NA | 3.2630290 |
| ASV15 | ASV15 | Bacteria | Firmicutes | Bacilli | Bacillales | Bacillaceae | Bacillus | NA | 0.0000000 |
| ASV16 | ASV16 | Bacteria | Proteobacteria | Gammaproteobacteria | Enterobacterales | Enterobacteriaceae | Escherichia-Shigella | NA | 0.0000000 |
| ASV17 | ASV17 | Bacteria | Proteobacteria | Gammaproteobacteria | Burkholderiales | Oxalobacteraceae | Massilia | NA | -2.2630312 |
# Export the table to a CSV file
write.csv(final_table_betula_vs_populus_LMM_605, file = "final_table_betula_vs_populus_LMM_605.csv", row.names = FALSE)
# Export the table to a tab-separated TXT file
write.table(final_table_betula_vs_populus_LMM_605, file = "final_table_betula_vs_populus_LMM_605.txt", sep = "\t", row.names = FALSE)
#-------------------------------------------------------------------------------
# Bar Plot
#-------------------------------------------------------------------------------
# Filter significant results (you can adjust the threshold for significance as needed)
significant_results_spp_LMM_605 <- subset(results_diff_abund_LMM_605, padj < 0.05)
#significant_results_spp_LMM_605 <- subset(results_diff_abund_LMM_605)
# Create a data frame with ASV names and log2 fold change values
data_for_barplot_LMM_605 <- data.frame(
ASV = rownames(significant_results_spp_LMM_605),
Log2FoldChange = significant_results_spp_LMM_605$log2FoldChange
)
data_for_barplot_605 <- as.data.frame(final_asv_table_spp_LMM_605)
data_for_barplot_605$Genus <- ifelse(is.na(data_for_barplot_605$Genus), "Unknown", data_for_barplot_605$Genus)
# Add a new column for the absolute values of Log2FoldChange
data_for_barplot_LMM_605$AbsLog2FoldChange <- abs(data_for_barplot_LMM_605$Log2FoldChange)
# Sort the data frame by the absolute values of Log2FoldChange in descending order
data_for_barplot_LMM_605 <- data_for_barplot_LMM_605[order(-data_for_barplot_LMM_605$AbsLog2FoldChange), ]
# Select the top 100 ASVs for the bar plot
data_for_barplot_LMM_605 <- data_for_barplot_LMM_605[1:25, ]
data_for_barplot_LMM_605 <- na.omit(data_for_barplot_LMM_605)
# Create the bar plot
deseq_plot605_genus <- ggplot(data_for_barplot_605, aes(x = ASV, y = Log2.Fold.Change, fill = Genus)) +
geom_bar(stat = "identity", color = "black") +
labs(x = "ASV", y = "Log2 Fold Change") +
theme_minimal() +
theme(
axis.title.x = element_text(size = 8),
axis.title.y = element_text(size = 8),
axis.text.x = element_text(angle = -90, hjust = 1, size = 6),
axis.text.y = element_text(size = 6),
legend.title = element_text(size = 12),
legend.text = element_text(size = 12),
panel.border = element_rect(color = "black", size = 1, fill = NA),
legend.position = "none",
axis.ticks = element_line(color = "black")
) +
scale_fill_manual(values = genus_colors)
deseq_plot605_genus
ggsave("deseq_plot605_genus.png", deseq_plot605_genus, width=12, height=8)
#-------------------------------------------------------------------------------
# Bubble Plot
#-------------------------------------------------------------------------------
library(forcats)
data_for_barplot_605$ASV <- factor(
data_for_barplot_605$ASV,
levels = data_for_barplot_605$ASV
)
# Create the bubble plot
deseq_plot605_genus2 <- ggplot(
data_for_barplot_605,
aes(
x = fct_reorder(ASV, Log2.Fold.Change, .fun = ~median(., na.rm = TRUE), .desc = TRUE),
y = Log2.Fold.Change,
fill = Genus
)
) +
geom_hline(yintercept = 0, linewidth = 0.4, color = "grey60") +
geom_point(aes(size = -log10(Adjusted.P.value)), shape = 21, stroke = 0.6, color = "black") + # bubble/circle points
# scale_x_discrete(expand = expansion(mult = c(0.04, 0.02))) +
scale_size_area(
name = expression(-log[10]("adj p")),
max_size = 5,
limits = c(0, NA),
guide = "none"
) +
labs(x = "ASV", y = "Log2 Fold Change") +
theme_minimal() +
theme(
axis.title.x = element_text(size = 6),
axis.title.y = element_text(size = 6),
axis.text.x = element_text(angle = -90, vjust = 0.5, size = 6),
axis.text.y = element_text(size = 6),
legend.title = element_text(size = 6),
legend.text = element_text(size = 5),
legend.box.margin = margin(0, 0, 0, -12, unit = "pt"),
panel.border = element_rect(color = "black", size = 1, fill = NA),
axis.ticks = element_line(color = "black"),
legend.position = "none"
) +
guides(fill = guide_legend(override.aes = list(size = 2), keyheight = 0.5, keywidth = 0.5, ncol = 2)) +
scale_fill_manual(
values = genus_colors,
labels = function(x) {
x <- str_replace(x, "Methylobacterium-Methylorubrum", "Methylobacterium-\nMethylorubrum")
x
}
)
deseq_plot605_genus2
deseq_plot605_phylum <- ggplot(data_for_barplot_605, aes(x = ASV, y = Log2.Fold.Change, fill = Phylum)) +
geom_bar(stat = "identity", color = "black") +
labs(x = "ASV", y = "Log2 Fold Change") +
theme_minimal() +
theme(
axis.title.x = element_text(size = 8),
axis.title.y = element_text(size = 8),
axis.text.x = element_text(angle = -90, hjust = 1, size = 6),
axis.text.y = element_text(size = 6),
legend.title = element_text(size = 12),
legend.text = element_text(size = 12),
panel.border = element_rect(color = "black", size = 1, fill = NA),
legend.position = "none",
axis.ticks = element_line(color = "black")
) +
scale_fill_manual(values = phylum_colors)
deseq_plot605_phylum
#ggsave("deseq_plot605_phylum.png", deseq_plot605_phylum, width=12, height=8)
################################################################################
# Bubble Plot
################################################################################
# Create the bubble plot
deseq_plot605_phylum2 <- ggplot(
data_for_barplot_605,
aes(
x = fct_reorder(ASV, Log2.Fold.Change, .fun = ~median(., na.rm = TRUE), .desc = TRUE),
y = Log2.Fold.Change,
fill = Phylum
)
) +
geom_hline(yintercept = 0, linewidth = 0.4, color = "grey60") +
geom_point(aes(size = -log10(Adjusted.P.value)), shape = 21, stroke = 0.6, color = "black") + # bubble/circle points
scale_size_continuous(
name = expression(-log[10]("adj p")),
# range = c(2, 4), # make min larger & max bigger; preserves proportions
guide = "none"
) +
labs(x = "ASV", y = "Log2 Fold Change") +
theme_minimal() +
theme(
axis.title.x = element_text(size = 6),
axis.title.y = element_text(size = 6),
axis.text.x = element_text(angle = -90, vjust = 0.5, size = 6),
axis.text.y = element_text(size = 6),
legend.title = element_text(size = 6),
legend.text = element_text(size = 5),
legend.box.margin = margin(0, 0, 0, -12, unit = "pt"),
panel.border = element_rect(color = "black", size = 1, fill = NA),
axis.ticks = element_line(color = "black")
) +
guides(fill = guide_legend(keyheight = 0.5, keywidth = 0.5)) +
scale_fill_manual(values = phylum_colors)
deseq_plot605_phylum2
#-------------------------------------------------------------------------------
## GDD 1087
#-------------------------------------------------------------------------------
# Get differential abundance results for tree species
results_diff_abund_LMM_1087 <- results(dds_1087, contrast=c("Species", "Betula_populifolia", "Populus_tremuloides"))
# Filter significant ASVs for species comparison
#significant_asvs_LMM_1087 <- subset(results_diff_abund_LMM_1087, padj < 0.05)
significant_asvs_LMM_1087 <- subset(results_diff_abund_LMM_1087)
head(significant_asvs_LMM_1087)
## log2 fold change (MLE): Species Betula_populifolia vs Populus_tremuloides
## Wald test p-value: Species Betula_populifolia vs Populus_tremuloides
## DataFrame with 6 rows and 6 columns
## baseMean log2FoldChange lfcSE stat pvalue padj
## <numeric> <numeric> <numeric> <numeric> <numeric> <numeric>
## ASV7 37.8182 6.35753e+00 1.477824 4.30195e+00 NA NA
## ASV8 12.9091 4.76553e+00 1.198504 3.97623e+00 7.00170e-05 1.34783e-03
## ASV9 18.9091 2.88886e+00 1.370867 2.10732e+00 3.50897e-02 7.73081e-02
## ASV10 135.8182 8.21722e+00 1.028011 7.99332e+00 1.31354e-15 1.01143e-13
## ASV12 80.1818 -2.01229e+00 1.143815 -1.75928e+00 7.85301e-02 9.91282e-02
## ASV13 1.0000 -2.03712e-16 0.912027 -2.23362e-16 1.00000e+00 NA
#-------------------------------------------------------------------------------
#ASV Heatmap:
#-------------------------------------------------------------------------------
# Assuming 'dds' is your DESeq2 object and 'top_asvs' is the data frame containing top ASVs
top_asv_names_LMM_1087 <- rownames(significant_asvs_LMM_1087)
top_asv_counts_LMM_1087 <- counts(dds_1087)[top_asv_names_LMM_1087, ]
# Create the heatmap
heatmap(as.matrix(top_asv_counts_LMM_1087), scale = "row", Rowv = FALSE, Colv = FALSE, col = viridis::viridis(100))
#-------------------------------------------------------------------------------
# Top ASVs for Species:
#-------------------------------------------------------------------------------
# Select the columns you want in the table
top_asv_table_spp_LMM_1087 <- significant_asvs_LMM_1087[, c("baseMean", "log2FoldChange", "lfcSE", "stat", "pvalue", "padj")]
# Optionally, you can add the taxonomic information if available
# Assuming you have a taxonomic table named 'tax_table' with a column 'Genus'
top_asv_table_spp_LMM_1087$Genus <- taxa_rdp[rownames(top_asv_table_spp_LMM_1087), "Genus"]
# Print the table
print(top_asv_table_spp_LMM_1087)
## log2 fold change (MLE): Species Betula_populifolia vs Populus_tremuloides
## Wald test p-value: Species Betula_populifolia vs Populus_tremuloides
## DataFrame with 1732 rows and 7 columns
## baseMean log2FoldChange lfcSE stat pvalue padj
## <numeric> <numeric> <numeric> <numeric> <numeric> <numeric>
## ASV7 37.8182 6.35753 1.47782 4.30195 NA NA
## ASV8 12.9091 4.76553 1.19850 3.97623 7.00170e-05 1.34783e-03
## ASV9 18.9091 2.88886 1.37087 2.10732 3.50897e-02 7.73081e-02
## ASV10 135.8182 8.21722 1.02801 7.99332 1.31354e-15 1.01143e-13
## ASV12 80.1818 -2.01229 1.14381 -1.75928 7.85301e-02 9.91282e-02
## ... ... ... ... ... ... ...
## ASV1786 1 -2.03712e-16 0.912027 -2.23362e-16 1 NA
## ASV1787 1 -2.03712e-16 0.912027 -2.23362e-16 1 NA
## ASV1788 1 -2.03712e-16 0.912027 -2.23362e-16 1 NA
## ASV1789 1 -2.03712e-16 0.912027 -2.23362e-16 1 NA
## ASV1790 1 -2.03712e-16 0.912027 -2.23362e-16 1 NA
## Genus
## <character>
## ASV7 Endobacter
## ASV8 Endobacter
## ASV9 1174-901-12
## ASV10 NA
## ASV12 Staphylococcus
## ... ...
## ASV1786 NA
## ASV1787 Conexibacter
## ASV1788 Methylobacterium-Met..
## ASV1789 NA
## ASV1790 NA
head(top_asv_table_spp_LMM_1087)
## log2 fold change (MLE): Species Betula_populifolia vs Populus_tremuloides
## Wald test p-value: Species Betula_populifolia vs Populus_tremuloides
## DataFrame with 6 rows and 7 columns
## baseMean log2FoldChange lfcSE stat pvalue padj
## <numeric> <numeric> <numeric> <numeric> <numeric> <numeric>
## ASV7 37.8182 6.35753e+00 1.477824 4.30195e+00 NA NA
## ASV8 12.9091 4.76553e+00 1.198504 3.97623e+00 7.00170e-05 1.34783e-03
## ASV9 18.9091 2.88886e+00 1.370867 2.10732e+00 3.50897e-02 7.73081e-02
## ASV10 135.8182 8.21722e+00 1.028011 7.99332e+00 1.31354e-15 1.01143e-13
## ASV12 80.1818 -2.01229e+00 1.143815 -1.75928e+00 7.85301e-02 9.91282e-02
## ASV13 1.0000 -2.03712e-16 0.912027 -2.23362e-16 1.00000e+00 NA
## Genus
## <character>
## ASV7 Endobacter
## ASV8 Endobacter
## ASV9 1174-901-12
## ASV10 NA
## ASV12 Staphylococcus
## ASV13 Limosilactobacillus
# Export the table to a CSV file
write.csv(top_asv_table_spp_LMM_1087, file = "top_asv_table_LMM_1087.csv", row.names = FALSE)
#-------------------------------------------------------------------------------
# Making Kable Table
#-------------------------------------------------------------------------------
# Filter significant results (you can adjust the threshold for significance as needed)
significant_results_spp_LMM_1087 <- subset(results_diff_abund_LMM_1087, padj < 0.05)
#significant_results_spp_LMM_1087 <- subset(results_diff_abund_LMM_1087)
# Get ASV names of differentially abundant ASVs
significant_asv_names_spp_LMM_1087 <- rownames(significant_results_spp_LMM_1087)
# Get the taxonomic information for the significant ASVs
significant_asv_tax_spp_LMM_1087 <- tax_table(ps_phen_asv_LMM)[significant_asv_names_spp_LMM_1087, ]
# Merge the results with taxonomic information
significant_results_table_spp_LMM_1087 <- cbind(significant_asv_tax_spp_LMM_1087, significant_results_spp_LMM_1087)
# Select columns of interest for the final table
final_asv_table_spp_LMM_1087 <- significant_results_table_spp_LMM_1087[, c("Kingdom", "Phylum", "Class", "Order", "Family", "Genus", "Species", "log2FoldChange", "pvalue", "padj")]
# Rename the columns for better presentation
colnames(final_asv_table_spp_LMM_1087) <- c("Kingdom", "Phylum", "Class", "Order", "Family", "Genus", "Species", "Log2 Fold Change", "P-value", "Adjusted P-value")
subset_final_asv_table_LMM_1087 <- final_asv_table_spp_LMM_1087[1:10, ]
# Get ASV names of differentially abundant ASVs
significant_asv_names_spp_LMM_1087 <- rownames(significant_results_spp_LMM_1087)
# Add the ASV information to the table as the first column
final_asv_table_spp_LMM_1087 <- cbind(ASV = significant_asv_names_spp_LMM_1087, final_asv_table_spp_LMM_1087)
# Display the final table
kable(subset_final_asv_table_LMM_1087, format = "html", align = "c") %>%
kable_styling(bootstrap_options = "striped", full_width = TRUE)
| Kingdom | Phylum | Class | Order | Family | Genus | Species | Log2.Fold.Change | P.value | Adjusted.P.value | |
|---|---|---|---|---|---|---|---|---|---|---|
| ASV8 | Bacteria | Proteobacteria | Alphaproteobacteria | Acetobacterales | Acetobacteraceae | Endobacter | NA | 4.765525 | 0.0000700 | 0.0013478 |
| ASV10 | Bacteria | Proteobacteria | NA | NA | NA | NA | NA | 8.217219 | 0.0000000 | 0.0000000 |
| ASV14 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | 1174-901-12 | NA | 4.472476 | 0.0007752 | 0.0074617 |
| ASV19 | Bacteria | Proteobacteria | NA | NA | NA | NA | NA | 6.095911 | 0.0000013 | 0.0000498 |
| ASV31 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | 1174-901-12 | NA | 3.292775 | 0.0055674 | 0.0260535 |
| ASV33 | Bacteria | Actinobacteriota | Actinobacteria | Kineosporiales | Kineosporiaceae | Quadrisphaera | NA | -5.321921 | 0.0000054 | 0.0001390 |
| ASV35 | Bacteria | NA | NA | NA | NA | NA | NA | 4.666747 | 0.0001594 | 0.0024543 |
| ASV36 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhodobacterales | Rhodobacteraceae | Rubellimicrobium | NA | -3.481121 | 0.0057521 | 0.0260535 |
| ASV42 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | 1174-901-12 | NA | 4.035615 | 0.0015438 | 0.0118870 |
| ASV44 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | Methylobacterium-Methylorubrum | NA | -3.459427 | 0.0032877 | 0.0210961 |
# Export the table to a CSV file
write.csv(final_asv_table_spp_LMM_1087, file = "final_asv_table_spp_LMM_1087.csv", row.names = FALSE)
# Export the table to a tab-separated TXT file
write.table(final_asv_table_spp_LMM_1087, file = "final_asv_table_spp_LMM_1087.txt", sep = "\t", row.names = FALSE)
#-------------------------------------------------------------------------------
#To see differences b/w Populus and Betula
#-------------------------------------------------------------------------------
# Filter results for the "Betula_populifolia vs Populus_tremuloides" comparison
results_betula_vs_populus_LMM_1087 <- results_diff_abund_LMM_1087[, "log2FoldChange", drop = FALSE]
# Add ASV names to the results
results_betula_vs_populus_LMM_1087$ASV <- rownames(results_diff_abund_LMM_1087)
# Merge with taxonomic information
results_betula_vs_populus_LMM_1087 <- cbind(results_betula_vs_populus_LMM_1087, tax_table(ps_phen_asv_LMM)[rownames(results_diff_abund_LMM_1087), ])
# Select the columns of interest for the final table
final_table_betula_vs_populus_LMM_1087 <- results_betula_vs_populus_LMM_1087[, c("ASV", "Kingdom", "Phylum", "Class", "Order", "Family", "Genus", "Species", "log2FoldChange")]
# Rename the columns for better presentation
colnames(final_table_betula_vs_populus_LMM_1087) <- c("ASV", "Kingdom", "Phylum", "Class", "Order", "Family", "Genus", "Species", "Log2 Fold Change")
subset_bet_vs_pop_LMM_1087 <- final_table_betula_vs_populus_LMM_1087[1:10, ]
# Display the final table
library(knitr)
kable(subset_bet_vs_pop_LMM_1087, format = "html", align = "c") %>%
kable_styling(bootstrap_options = "striped", full_width = TRUE)
| ASV | Kingdom | Phylum | Class | Order | Family | Genus | Species | Log2.Fold.Change | |
|---|---|---|---|---|---|---|---|---|---|
| ASV7 | ASV7 | Bacteria | Proteobacteria | Alphaproteobacteria | Acetobacterales | Acetobacteraceae | Endobacter | NA | 6.357532 |
| ASV8 | ASV8 | Bacteria | Proteobacteria | Alphaproteobacteria | Acetobacterales | Acetobacteraceae | Endobacter | NA | 4.765525 |
| ASV9 | ASV9 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | 1174-901-12 | NA | 2.888859 |
| ASV10 | ASV10 | Bacteria | Proteobacteria | NA | NA | NA | NA | NA | 8.217219 |
| ASV12 | ASV12 | Bacteria | Firmicutes | Bacilli | Staphylococcales | Staphylococcaceae | Staphylococcus | NA | -2.012289 |
| ASV13 | ASV13 | Bacteria | Firmicutes | Bacilli | Lactobacillales | Lactobacillaceae | Limosilactobacillus | NA | 0.000000 |
| ASV14 | ASV14 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | 1174-901-12 | NA | 4.472476 |
| ASV15 | ASV15 | Bacteria | Firmicutes | Bacilli | Bacillales | Bacillaceae | Bacillus | NA | 0.000000 |
| ASV16 | ASV16 | Bacteria | Proteobacteria | Gammaproteobacteria | Enterobacterales | Enterobacteriaceae | Escherichia-Shigella | NA | 0.000000 |
| ASV17 | ASV17 | Bacteria | Proteobacteria | Gammaproteobacteria | Burkholderiales | Oxalobacteraceae | Massilia | NA | -3.906882 |
# Export the table to a CSV file
write.csv(final_table_betula_vs_populus_LMM_1087, file = "final_table_betula_vs_populus_LMM_1087.csv", row.names = FALSE)
# Export the table to a tab-separated TXT file
write.table(final_table_betula_vs_populus_LMM_1087, file = "final_table_betula_vs_populus_LMM_1087.txt", sep = "\t", row.names = FALSE)
#-------------------------------------------------------------------------------
# Bar Plot
#-------------------------------------------------------------------------------
# Filter significant results (you can adjust the threshold for significance as needed)
significant_results_spp_LMM_1087 <- subset(results_diff_abund_LMM_1087, padj < 0.05)
#significant_results_spp_LMM_1087 <- subset(results_diff_abund_LMM_1087)
# Create a data frame with ASV names and log2 fold change values
data_for_barplot_LMM_1087 <- data.frame(
ASV = rownames(significant_results_spp_LMM_1087),
Log2FoldChange = significant_results_spp_LMM_1087$log2FoldChange
)
data_for_barplot_1087 <- as.data.frame(final_asv_table_spp_LMM_1087)
data_for_barplot_1087$Genus <- ifelse(is.na(data_for_barplot_1087$Genus), "Unknown", data_for_barplot_1087$Genus)
# Add a new column for the absolute values of Log2FoldChange
data_for_barplot_LMM_1087$AbsLog2FoldChange <- abs(data_for_barplot_LMM_1087$Log2FoldChange)
# Sort the data frame by the absolute values of Log2FoldChange in descending order
data_for_barplot_LMM_1087 <- data_for_barplot_LMM_1087[order(-data_for_barplot_LMM_1087$AbsLog2FoldChange), ]
# Select the top 100 ASVs for the bar plot
data_for_barplot_LMM_1087 <- data_for_barplot_LMM_1087[1:25, ]
data_for_barplot_LMM_1087 <- na.omit(data_for_barplot_LMM_1087)
# Create the bar plot
deseq_plot1087_genus <- ggplot(data_for_barplot_1087, aes(x = ASV, y = Log2.Fold.Change, fill = Genus)) +
geom_bar(stat = "identity", color = "black") +
labs(x = "ASV", y = "Log2 Fold Change") +
theme_minimal() +
theme(
axis.title.x = element_text(size = 8),
axis.title.y = element_text(size = 8),
axis.text.x = element_text(angle = -90, hjust = 1, size = 6),
axis.text.y = element_text(size = 6),
legend.title = element_text(size = 12),
legend.text = element_text(size = 12),
panel.border = element_rect(color = "black", size = 1, fill = NA),
legend.position = "none",
axis.ticks = element_line(color = "black")
) +
scale_fill_manual(values = genus_colors)
deseq_plot1087_genus
ggsave("deseq_plot1087_genus.png", deseq_plot1087_genus, width=12, height=8)
#-------------------------------------------------------------------------------
# Bubble Plot
#-------------------------------------------------------------------------------
# Create the bubble plot
deseq_plot1087_genus2 <- ggplot(
data_for_barplot_1087,
aes(
x = fct_reorder(ASV, Log2.Fold.Change, .fun = ~median(., na.rm = TRUE), .desc = TRUE),
y = Log2.Fold.Change,
fill = Genus
)
) +
geom_hline(yintercept = 0, linewidth = 0.4, color = "grey60") +
geom_point(aes(size = -log10(Adjusted.P.value)), shape = 21, stroke = 0.6, color = "black") + # bubble/circle points
# scale_x_discrete(expand = expansion(mult = c(0.04, 0.02))) +
scale_size_area(
name = expression(-log[10]("adj p")),
max_size = 5,
limits = c(0, NA),
guide = "none"
) +
labs(x = "ASV", y = "Log2 Fold Change") +
theme_minimal() +
theme(
axis.title.x = element_text(size = 6),
axis.title.y = element_text(size = 6),
axis.text.x = element_text(angle = -90, vjust = 0.5, size = 6),
axis.text.y = element_text(size = 6),
legend.title = element_text(size = 6),
legend.text = element_text(size = 5),
legend.box.margin = margin(0, 0, 0, -12, unit = "pt"),
panel.border = element_rect(color = "black", size = 1, fill = NA),
axis.ticks = element_line(color = "black"),
legend.position = "none"
) +
guides(fill = guide_legend(override.aes = list(size = 2), keyheight = 0.5, keywidth = 0.5, ncol = 2)) +
scale_fill_manual(
values = genus_colors,
labels = function(x) {
x <- str_replace(x, "Methylobacterium-Methylorubrum", "Methylobacterium-\nMethylorubrum")
x
}
)
deseq_plot1087_genus2
deseq_plot1087_phylum <- ggplot(data_for_barplot_1087, aes(x = ASV, y = Log2.Fold.Change, fill = Phylum)) +
geom_bar(stat = "identity", color = "black") +
labs(x = "ASV", y = "Log2 Fold Change") +
theme_minimal() +
theme(
axis.title.x = element_text(size = 8),
axis.title.y = element_text(size = 8),
axis.text.x = element_text(angle = -90, hjust = 1, size = 6),
axis.text.y = element_text(size = 6),
legend.title = element_text(size = 12),
legend.text = element_text(size = 12),
panel.border = element_rect(color = "black", size = 1, fill = NA),
legend.position = "none",
axis.ticks = element_line(color = "black")
) +
scale_fill_manual(values = phylum_colors)
deseq_plot1087_phylum
#ggsave("deseq_plot1087_phylum.png", deseq_plot1087_phylum, width=12, height=8)
#-------------------------------------------------------------------------------
# Bubble Plot
#-------------------------------------------------------------------------------
# Create the bubble plot
deseq_plot1087_phylum2 <- ggplot(
data_for_barplot_1087,
aes(
x = fct_reorder(ASV, Log2.Fold.Change, .fun = ~median(., na.rm = TRUE), .desc = TRUE),
y = Log2.Fold.Change,
fill = Phylum
)
) +
geom_hline(yintercept = 0, linewidth = 0.4, color = "grey60") +
geom_point(aes(size = -log10(Adjusted.P.value)), shape = 21, stroke = 0.6, color = "black") + # bubble/circle points
scale_size_continuous(
name = expression(-log[10]("adj p")),
# range = c(2, 4), # make min larger & max bigger; preserves proportions
guide = "none"
) +
labs(x = "ASV", y = "Log2 Fold Change") +
theme_minimal() +
theme(
axis.title.x = element_text(size = 6),
axis.title.y = element_text(size = 6),
axis.text.x = element_text(angle = -90, vjust = 0.5, size = 6),
axis.text.y = element_text(size = 6),
legend.title = element_text(size = 6),
legend.text = element_text(size = 5),
legend.box.margin = margin(0, 0, 0, -12, unit = "pt"),
panel.border = element_rect(color = "black", size = 1, fill = NA),
axis.ticks = element_line(color = "black")
) +
guides(fill = guide_legend(keyheight = 0.5, keywidth = 0.5)) +
scale_fill_manual(values = phylum_colors)
deseq_plot1087_phylum2
#-------------------------------------------------------------------------------
## GDD 1606
#-------------------------------------------------------------------------------
# Get differential abundance results for tree species
results_diff_abund_LMM_1606 <- results(dds_1606, contrast=c("Species", "Betula_populifolia", "Populus_tremuloides"))
# Filter significant ASVs for species comparison
#significant_asvs_LMM_1606 <- subset(results_diff_abund_LMM_1606, padj < 0.05)
significant_asvs_LMM_1606 <- subset(results_diff_abund_LMM_1606)
head(significant_asvs_LMM_1606)
## log2 fold change (MLE): Species Betula_populifolia vs Populus_tremuloides
## Wald test p-value: Species Betula_populifolia vs Populus_tremuloides
## DataFrame with 6 rows and 6 columns
## baseMean log2FoldChange lfcSE stat pvalue padj
## <numeric> <numeric> <numeric> <numeric> <numeric> <numeric>
## ASV7 177.7 8.46920e+00 1.802053 4.69975e+00 NA NA
## ASV8 142.2 7.65921e+00 1.441219 5.31440e+00 NA NA
## ASV9 42.4 6.38886e+00 1.437692 4.44383e+00 8.83706e-06 1.59067e-04
## ASV10 227.0 8.82335e+00 1.238944 7.12167e+00 1.06627e-12 7.67711e-11
## ASV12 283.0 -4.07028e+00 1.444570 -2.81764e+00 NA NA
## ASV13 1.0 -2.05834e-16 0.957294 -2.15016e-16 1.00000e+00 NA
#-------------------------------------------------------------------------------
#ASV Heatmap:
#-------------------------------------------------------------------------------
# Assuming 'dds' is your DESeq2 object and 'top_asvs' is the data frame containing top ASVs
top_asv_names_LMM_1606 <- rownames(significant_asvs_LMM_1606)
top_asv_counts_LMM_1606 <- counts(dds_1606)[top_asv_names_LMM_1606, ]
# Create the heatmap
heatmap(as.matrix(top_asv_counts_LMM_1606), scale = "row", Rowv = FALSE, Colv = FALSE, col = viridis::viridis(100))
#-------------------------------------------------------------------------------
# Top ASVs for Species:
#-------------------------------------------------------------------------------
# Select the columns you want in the table
top_asv_table_spp_LMM_1606 <- significant_asvs_LMM_1606[, c("baseMean", "log2FoldChange", "lfcSE", "stat", "pvalue", "padj")]
# Optionally, you can add the taxonomic information if available
# Assuming you have a taxonomic table named 'tax_table' with a column 'Genus'
top_asv_table_spp_LMM_1606$Genus <- taxa_rdp[rownames(top_asv_table_spp_LMM_1606), "Genus"]
# Print the table
print(top_asv_table_spp_LMM_1606)
## log2 fold change (MLE): Species Betula_populifolia vs Populus_tremuloides
## Wald test p-value: Species Betula_populifolia vs Populus_tremuloides
## DataFrame with 1732 rows and 7 columns
## baseMean log2FoldChange lfcSE stat pvalue padj
## <numeric> <numeric> <numeric> <numeric> <numeric> <numeric>
## ASV7 177.7 8.46920 1.80205 4.69975 NA NA
## ASV8 142.2 7.65921 1.44122 5.31440 NA NA
## ASV9 42.4 6.38886 1.43769 4.44383 8.83706e-06 1.59067e-04
## ASV10 227.0 8.82335 1.23894 7.12167 1.06627e-12 7.67711e-11
## ASV12 283.0 -4.07028 1.44457 -2.81764 NA NA
## ... ... ... ... ... ... ...
## ASV1786 1 -2.05834e-16 0.957294 -2.15016e-16 1 NA
## ASV1787 1 -2.05834e-16 0.957294 -2.15016e-16 1 NA
## ASV1788 1 -2.05834e-16 0.957294 -2.15016e-16 1 NA
## ASV1789 1 -2.05834e-16 0.957294 -2.15016e-16 1 NA
## ASV1790 1 -2.05834e-16 0.957294 -2.15016e-16 1 NA
## Genus
## <character>
## ASV7 Endobacter
## ASV8 Endobacter
## ASV9 1174-901-12
## ASV10 NA
## ASV12 Staphylococcus
## ... ...
## ASV1786 NA
## ASV1787 Conexibacter
## ASV1788 Methylobacterium-Met..
## ASV1789 NA
## ASV1790 NA
head(top_asv_table_spp_LMM_1606)
## log2 fold change (MLE): Species Betula_populifolia vs Populus_tremuloides
## Wald test p-value: Species Betula_populifolia vs Populus_tremuloides
## DataFrame with 6 rows and 7 columns
## baseMean log2FoldChange lfcSE stat pvalue padj
## <numeric> <numeric> <numeric> <numeric> <numeric> <numeric>
## ASV7 177.7 8.46920e+00 1.802053 4.69975e+00 NA NA
## ASV8 142.2 7.65921e+00 1.441219 5.31440e+00 NA NA
## ASV9 42.4 6.38886e+00 1.437692 4.44383e+00 8.83706e-06 1.59067e-04
## ASV10 227.0 8.82335e+00 1.238944 7.12167e+00 1.06627e-12 7.67711e-11
## ASV12 283.0 -4.07028e+00 1.444570 -2.81764e+00 NA NA
## ASV13 1.0 -2.05834e-16 0.957294 -2.15016e-16 1.00000e+00 NA
## Genus
## <character>
## ASV7 Endobacter
## ASV8 Endobacter
## ASV9 1174-901-12
## ASV10 NA
## ASV12 Staphylococcus
## ASV13 Limosilactobacillus
# Export the table to a CSV file
write.csv(top_asv_table_spp_LMM_1606, file = "top_asv_table_LMM_1606.csv", row.names = FALSE)
#-------------------------------------------------------------------------------
# Making Kable Table
#-------------------------------------------------------------------------------
# Filter significant results (you can adjust the threshold for significance as needed)
significant_results_spp_LMM_1606 <- subset(results_diff_abund_LMM_1606, padj < 0.05)
#significant_results_spp_LMM_1606 <- subset(results_diff_abund_LMM_1606)
# Get ASV names of differentially abundant ASVs
significant_asv_names_spp_LMM_1606 <- rownames(significant_results_spp_LMM_1606)
# Get the taxonomic information for the significant ASVs
significant_asv_tax_spp_LMM_1606 <- tax_table(ps_phen_asv_LMM)[significant_asv_names_spp_LMM_1606, ]
# Merge the results with taxonomic information
significant_results_table_spp_LMM_1606 <- cbind(significant_asv_tax_spp_LMM_1606, significant_results_spp_LMM_1606)
# Select columns of interest for the final table
final_asv_table_spp_LMM_1606 <- significant_results_table_spp_LMM_1606[, c("Kingdom", "Phylum", "Class", "Order", "Family", "Genus", "Species", "log2FoldChange", "pvalue", "padj")]
# Rename the columns for better presentation
colnames(final_asv_table_spp_LMM_1606) <- c("Kingdom", "Phylum", "Class", "Order", "Family", "Genus", "Species", "Log2 Fold Change", "P-value", "Adjusted P-value")
subset_final_asv_table_LMM_1606 <- final_asv_table_spp_LMM_1606[1:10, ]
# Get ASV names of differentially abundant ASVs
significant_asv_names_spp_LMM_1606 <- rownames(significant_results_spp_LMM_1606)
# Add the ASV information to the table as the first column
final_asv_table_spp_LMM_1606 <- cbind(ASV = significant_asv_names_spp_LMM_1606, final_asv_table_spp_LMM_1606)
# Display the final table
kable(subset_final_asv_table_LMM_1606, format = "html", align = "c") %>%
kable_styling(bootstrap_options = "striped", full_width = TRUE)
| Kingdom | Phylum | Class | Order | Family | Genus | Species | Log2.Fold.Change | P.value | Adjusted.P.value | |
|---|---|---|---|---|---|---|---|---|---|---|
| ASV9 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | 1174-901-12 | NA | 6.388860 | 0.0000088 | 0.0001591 |
| ASV10 | Bacteria | Proteobacteria | NA | NA | NA | NA | NA | 8.823349 | 0.0000000 | 0.0000000 |
| ASV14 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | 1174-901-12 | NA | 4.940829 | 0.0000172 | 0.0002476 |
| ASV19 | Bacteria | Proteobacteria | NA | NA | NA | NA | NA | 6.135439 | 0.0000008 | 0.0000195 |
| ASV25 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | 1174-901-12 | NA | 4.596922 | 0.0010952 | 0.0098565 |
| ASV28 | Bacteria | Myxococcota | Myxococcia | Myxococcales | Myxococcaceae | P3OB-42 | NA | 4.330377 | 0.0009985 | 0.0098565 |
| ASV35 | Bacteria | NA | NA | NA | NA | NA | NA | 6.193760 | 0.0000001 | 0.0000047 |
| ASV44 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | Methylobacterium-Methylorubrum | NA | -4.307420 | 0.0019969 | 0.0143776 |
| ASV49 | Bacteria | Myxococcota | Myxococcia | Myxococcales | Myxococcaceae | P3OB-42 | NA | 6.133379 | 0.0000629 | 0.0007553 |
| ASV105 | Bacteria | NA | NA | NA | NA | NA | NA | 3.999991 | 0.0016754 | 0.0134032 |
# Export the table to a CSV file
write.csv(final_asv_table_spp_LMM_1606, file = "final_asv_table_spp_LMM_1606.csv", row.names = FALSE)
# Export the table to a tab-separated TXT file
write.table(final_asv_table_spp_LMM_1606, file = "final_asv_table_spp_LMM_1606.txt", sep = "\t", row.names = FALSE)
#-------------------------------------------------------------------------------
#To see differences b/w Populus and Betula
#-------------------------------------------------------------------------------
# Filter results for the "Betula_populifolia vs Populus_tremuloides" comparison
results_betula_vs_populus_LMM_1606 <- results_diff_abund_LMM_1606[, "log2FoldChange", drop = FALSE]
# Add ASV names to the results
results_betula_vs_populus_LMM_1606$ASV <- rownames(results_diff_abund_LMM_1606)
# Merge with taxonomic information
results_betula_vs_populus_LMM_1606 <- cbind(results_betula_vs_populus_LMM_1606, tax_table(ps_phen_asv_LMM)[rownames(results_diff_abund_LMM_1606), ])
# Select the columns of interest for the final table
final_table_betula_vs_populus_LMM_1606 <- results_betula_vs_populus_LMM_1606[, c("ASV", "Kingdom", "Phylum", "Class", "Order", "Family", "Genus", "Species", "log2FoldChange")]
# Rename the columns for better presentation
colnames(final_table_betula_vs_populus_LMM_1606) <- c("ASV", "Kingdom", "Phylum", "Class", "Order", "Family", "Genus", "Species", "Log2 Fold Change")
subset_bet_vs_pop_LMM_1606 <- final_table_betula_vs_populus_LMM_1606[1:10, ]
# Display the final table
library(knitr)
kable(subset_bet_vs_pop_LMM_1606, format = "html", align = "c") %>%
kable_styling(bootstrap_options = "striped", full_width = TRUE)
| ASV | Kingdom | Phylum | Class | Order | Family | Genus | Species | Log2.Fold.Change | |
|---|---|---|---|---|---|---|---|---|---|
| ASV7 | ASV7 | Bacteria | Proteobacteria | Alphaproteobacteria | Acetobacterales | Acetobacteraceae | Endobacter | NA | 8.4691952 |
| ASV8 | ASV8 | Bacteria | Proteobacteria | Alphaproteobacteria | Acetobacterales | Acetobacteraceae | Endobacter | NA | 7.6592083 |
| ASV9 | ASV9 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | 1174-901-12 | NA | 6.3888598 |
| ASV10 | ASV10 | Bacteria | Proteobacteria | NA | NA | NA | NA | NA | 8.8233488 |
| ASV12 | ASV12 | Bacteria | Firmicutes | Bacilli | Staphylococcales | Staphylococcaceae | Staphylococcus | NA | -4.0702781 |
| ASV13 | ASV13 | Bacteria | Firmicutes | Bacilli | Lactobacillales | Lactobacillaceae | Limosilactobacillus | NA | 0.0000000 |
| ASV14 | ASV14 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | 1174-901-12 | NA | 4.9408286 |
| ASV15 | ASV15 | Bacteria | Firmicutes | Bacilli | Bacillales | Bacillaceae | Bacillus | NA | 0.0000000 |
| ASV16 | ASV16 | Bacteria | Proteobacteria | Gammaproteobacteria | Enterobacterales | Enterobacteriaceae | Escherichia-Shigella | NA | 0.0000000 |
| ASV17 | ASV17 | Bacteria | Proteobacteria | Gammaproteobacteria | Burkholderiales | Oxalobacteraceae | Massilia | NA | -0.1993129 |
# Export the table to a CSV file
write.csv(final_table_betula_vs_populus_LMM_1606, file = "final_table_betula_vs_populus_LMM_1606.csv", row.names = FALSE)
# Export the table to a tab-separated TXT file
write.table(final_table_betula_vs_populus_LMM_1606, file = "final_table_betula_vs_populus_LMM_1606.txt", sep = "\t", row.names = FALSE)
#-------------------------------------------------------------------------------
# Bar Plot
#-------------------------------------------------------------------------------
# Filter significant results (you can adjust the threshold for significance as needed)
significant_results_spp_LMM_1606 <- subset(results_diff_abund_LMM_1606, padj < 0.05)
#significant_results_spp_LMM_1606 <- subset(results_diff_abund_LMM_1606)
# Create a data frame with ASV names and log2 fold change values
data_for_barplot_LMM_1606 <- data.frame(
ASV = rownames(significant_results_spp_LMM_1606),
Log2FoldChange = significant_results_spp_LMM_1606$log2FoldChange
)
data_for_barplot_1606 <- as.data.frame(final_asv_table_spp_LMM_1606)
data_for_barplot_1606$Genus <- ifelse(is.na(data_for_barplot_1606$Genus), "Unknown", data_for_barplot_1606$Genus)
# Add a new column for the absolute values of Log2FoldChange
data_for_barplot_LMM_1606$AbsLog2FoldChange <- abs(data_for_barplot_LMM_1606$Log2FoldChange)
# Sort the data frame by the absolute values of Log2FoldChange in descending order
data_for_barplot_LMM_1606 <- data_for_barplot_LMM_1606[order(-data_for_barplot_LMM_1606$AbsLog2FoldChange), ]
# Select the top 100 ASVs for the bar plot
data_for_barplot_LMM_1606 <- data_for_barplot_LMM_1606[1:25, ]
data_for_barplot_LMM_1606 <- na.omit(data_for_barplot_LMM_1606)
# Create the bar plot
deseq_plot1606_genus <- ggplot(data_for_barplot_1606, aes(x = ASV, y = Log2.Fold.Change, fill = Genus)) +
geom_bar(stat = "identity", color = "black") +
labs(x = "ASV", y = "Log2 Fold Change") +
theme_minimal() +
theme(
axis.title.x = element_text(size = 8),
axis.title.y = element_text(size = 8),
axis.text.x = element_text(angle = -90, hjust = 1, size = 6),
axis.text.y = element_text(size = 6),
legend.title = element_text(size = 12),
legend.text = element_text(size = 12),
panel.border = element_rect(color = "black", size = 1, fill = NA),
legend.position = "none",
axis.ticks = element_line(color = "black")
) +
scale_fill_manual(values = genus_colors)
deseq_plot1606_genus
ggsave("deseq_plot1606_genus.png", deseq_plot1606_genus, width=12, height=8)
#-------------------------------------------------------------------------------
# Bubble Plot
#-------------------------------------------------------------------------------
# Create the bubble plot
deseq_plot1606_genus2 <- ggplot(
data_for_barplot_1606,
aes(
x = fct_reorder(ASV, Log2.Fold.Change, .fun = ~median(., na.rm = TRUE), .desc = TRUE),
y = Log2.Fold.Change,
fill = Genus
)
) +
geom_hline(yintercept = 0, linewidth = 0.4, color = "grey60") +
geom_point(aes(size = -log10(Adjusted.P.value)), shape = 21, stroke = 0.6, color = "black") + # bubble/circle points
# scale_x_discrete(expand = expansion(mult = c(0.04, 0.02))) +
scale_size_area(
name = expression(-log[10]("adj p")),
max_size = 5,
limits = c(0, NA),
guide = "none"
) +
labs(x = "ASV", y = "Log2 Fold Change") +
theme_minimal() +
theme(
axis.title.x = element_text(size = 6),
axis.title.y = element_text(size = 6),
axis.text.x = element_text(angle = -90, vjust = 0.5, size = 6),
axis.text.y = element_text(size = 6),
legend.title = element_text(size = 6),
legend.text = element_text(size = 5),
legend.box.margin = margin(0, 0, 0, -12, unit = "pt"),
panel.border = element_rect(color = "black", size = 1, fill = NA),
axis.ticks = element_line(color = "black"),
legend.position = "none"
) +
guides(fill = guide_legend(override.aes = list(size = 2), keyheight = 0.5, keywidth = 0.5, ncol = 2)) +
scale_fill_manual(
values = genus_colors,
labels = function(x) {
x <- str_replace(x, "Methylobacterium-Methylorubrum", "Methylobacterium-\nMethylorubrum")
x
}
)
deseq_plot1606_genus2
# Create the bar plot
deseq_plot1606_phylum <- ggplot(data_for_barplot_1606, aes(
x = fct_reorder(ASV, Log2.Fold.Change, .fun = ~median(., na.rm = TRUE), .desc = TRUE),
y = Log2.Fold.Change,
fill = Phylum
)
) +
geom_bar(stat = "identity", color = "black") +
labs(x = "ASV", y = "Log2 Fold Change") +
theme_minimal() +
theme(
axis.title.x = element_text(size = 8),
axis.title.y = element_text(size = 8),
axis.text.x = element_text(angle = -90, hjust = 1, size = 6),
axis.text.y = element_text(size = 6),
legend.title = element_text(size = 12),
legend.text = element_text(size = 12),
panel.border = element_rect(color = "black", size = 1, fill = NA),
legend.position = "none",
axis.ticks = element_line(color = "black")
) +
scale_fill_manual(values = phylum_colors)
deseq_plot1606_phylum
#ggsave("deseq_plot1606_phylum.png", deseq_plot1606_phylum, width=12, height=8)
#-------------------------------------------------------------------------------
# Bubble Plot
#-------------------------------------------------------------------------------
# Create the bubble plot
deseq_plot1606_phylum2 <- ggplot(
data_for_barplot_1606,
aes(x = ASV, y = Log2.Fold.Change, fill = Phylum)
) +
geom_hline(yintercept = 0, linewidth = 0.4, color = "grey60") +
geom_point(aes(size = -log10(Adjusted.P.value)), shape = 21, stroke = 0.6, color = "black") + # bubble/circle points
scale_size_continuous(
name = expression(-log[10]("adj p")),
# range = c(2, 4), # make min larger & max bigger; preserves proportions
guide = "none"
) +
labs(x = "ASV", y = "Log2 Fold Change") +
theme_minimal() +
theme(
axis.title.x = element_text(size = 6),
axis.title.y = element_text(size = 6),
axis.text.x = element_text(angle = -90, vjust = 0.5, size = 6),
axis.text.y = element_text(size = 6),
legend.title = element_text(size = 6),
legend.text = element_text(size = 5),
legend.box.margin = margin(0, 0, 0, -12, unit = "pt"),
panel.border = element_rect(color = "black", size = 1, fill = NA),
axis.ticks = element_line(color = "black")
) +
guides(fill = guide_legend(keyheight = 0.5, keywidth = 0.5)) +
scale_fill_manual(values = phylum_colors)
deseq_plot1606_phylum2
#-------------------------------------------------------------------------------
## GDD 1992
#-------------------------------------------------------------------------------
# Get differential abundance results for tree species
results_diff_abund_LMM_1992 <- results(dds_1992, contrast=c("Species", "Betula_populifolia", "Populus_tremuloides"))
# Filter significant ASVs for species comparison
#significant_asvs_LMM_1992 <- subset(results_diff_abund_LMM_1992, padj < 0.05)
significant_asvs_LMM_1992 <- subset(results_diff_abund_LMM_1992)
head(significant_asvs_LMM_1992)
## log2 fold change (MLE): Species Betula_populifolia vs Populus_tremuloides
## Wald test p-value: Species Betula_populifolia vs Populus_tremuloides
## DataFrame with 6 rows and 6 columns
## baseMean log2FoldChange lfcSE stat pvalue padj
## <numeric> <numeric> <numeric> <numeric> <numeric> <numeric>
## ASV7 306.4 7.48569e+00 1.364915 5.48436e+00 4.14964e-08 1.05124e-06
## ASV8 196.8 7.61322e+00 1.334032 5.70692e+00 1.15038e-08 4.37146e-07
## ASV9 206.3 5.85653e+00 1.598913 3.66282e+00 2.49452e-04 1.57986e-03
## ASV10 180.4 8.49103e+00 1.374772 6.17632e+00 6.56129e-10 4.98658e-08
## ASV12 27.6 2.17632e+00 1.122104 1.93950e+00 5.24410e-02 7.97103e-02
## ASV13 1.0 -2.08663e-16 0.963535 -2.16559e-16 1.00000e+00 NA
#-------------------------------------------------------------------------------
#ASV Heatmap:
#-------------------------------------------------------------------------------
# Assuming 'dds' is your DESeq2 object and 'top_asvs' is the data frame containing top ASVs
top_asv_names_LMM_1992 <- rownames(significant_asvs_LMM_1992)
top_asv_counts_LMM_1992 <- counts(dds_1992)[top_asv_names_LMM_1992, ]
# Create the heatmap
heatmap(as.matrix(top_asv_counts_LMM_1992), scale = "row", Rowv = FALSE, Colv = FALSE, col = viridis::viridis(100))
#-------------------------------------------------------------------------------
# Top ASVs for Species:
#-------------------------------------------------------------------------------
# Select the columns you want in the table
top_asv_table_spp_LMM_1992 <- significant_asvs_LMM_1992[, c("baseMean", "log2FoldChange", "lfcSE", "stat", "pvalue", "padj")]
# Optionally, you can add the taxonomic information if available
# Assuming you have a taxonomic table named 'tax_table' with a column 'Genus'
top_asv_table_spp_LMM_1992$Genus <- taxa_rdp[rownames(top_asv_table_spp_LMM_1992), "Genus"]
# Print the table
print(top_asv_table_spp_LMM_1992)
## log2 fold change (MLE): Species Betula_populifolia vs Populus_tremuloides
## Wald test p-value: Species Betula_populifolia vs Populus_tremuloides
## DataFrame with 1732 rows and 7 columns
## baseMean log2FoldChange lfcSE stat pvalue padj
## <numeric> <numeric> <numeric> <numeric> <numeric> <numeric>
## ASV7 306.4 7.48569 1.36492 5.48436 4.14964e-08 1.05124e-06
## ASV8 196.8 7.61322 1.33403 5.70692 1.15038e-08 4.37146e-07
## ASV9 206.3 5.85653 1.59891 3.66282 2.49452e-04 1.57986e-03
## ASV10 180.4 8.49103 1.37477 6.17632 6.56129e-10 4.98658e-08
## ASV12 27.6 2.17632 1.12210 1.93950 5.24410e-02 7.97103e-02
## ... ... ... ... ... ... ...
## ASV1786 1.0 -2.08663e-16 0.963535 -2.16559e-16 1.000000 NA
## ASV1787 1.2 4.85426e-01 0.925909 5.24270e-01 0.600091 NA
## ASV1788 1.2 4.85426e-01 0.925909 5.24270e-01 0.600091 NA
## ASV1789 1.2 4.85426e-01 0.925909 5.24270e-01 0.600091 NA
## ASV1790 1.0 -2.08663e-16 0.963535 -2.16559e-16 1.000000 NA
## Genus
## <character>
## ASV7 Endobacter
## ASV8 Endobacter
## ASV9 1174-901-12
## ASV10 NA
## ASV12 Staphylococcus
## ... ...
## ASV1786 NA
## ASV1787 Conexibacter
## ASV1788 Methylobacterium-Met..
## ASV1789 NA
## ASV1790 NA
head(top_asv_table_spp_LMM_1992)
## log2 fold change (MLE): Species Betula_populifolia vs Populus_tremuloides
## Wald test p-value: Species Betula_populifolia vs Populus_tremuloides
## DataFrame with 6 rows and 7 columns
## baseMean log2FoldChange lfcSE stat pvalue padj
## <numeric> <numeric> <numeric> <numeric> <numeric> <numeric>
## ASV7 306.4 7.48569e+00 1.364915 5.48436e+00 4.14964e-08 1.05124e-06
## ASV8 196.8 7.61322e+00 1.334032 5.70692e+00 1.15038e-08 4.37146e-07
## ASV9 206.3 5.85653e+00 1.598913 3.66282e+00 2.49452e-04 1.57986e-03
## ASV10 180.4 8.49103e+00 1.374772 6.17632e+00 6.56129e-10 4.98658e-08
## ASV12 27.6 2.17632e+00 1.122104 1.93950e+00 5.24410e-02 7.97103e-02
## ASV13 1.0 -2.08663e-16 0.963535 -2.16559e-16 1.00000e+00 NA
## Genus
## <character>
## ASV7 Endobacter
## ASV8 Endobacter
## ASV9 1174-901-12
## ASV10 NA
## ASV12 Staphylococcus
## ASV13 Limosilactobacillus
# Export the table to a CSV file
write.csv(top_asv_table_spp_LMM_1992, file = "top_asv_table_LMM_1992.csv", row.names = FALSE)
#-------------------------------------------------------------------------------
# Making Kable Table
#-------------------------------------------------------------------------------
# Filter significant results (you can adjust the threshold for significance as needed)
significant_results_spp_LMM_1992 <- subset(results_diff_abund_LMM_1992, padj < 0.05)
#significant_results_spp_LMM_1992 <- subset(results_diff_abund_LMM_1992)
# Get ASV names of differentially abundant ASVs
significant_asv_names_spp_LMM_1992 <- rownames(significant_results_spp_LMM_1992)
# Get the taxonomic information for the significant ASVs
significant_asv_tax_spp_LMM_1992 <- tax_table(ps_phen_asv_LMM)[significant_asv_names_spp_LMM_1992, ]
# Merge the results with taxonomic information
significant_results_table_spp_LMM_1992 <- cbind(significant_asv_tax_spp_LMM_1992, significant_results_spp_LMM_1992)
# Select columns of interest for the final table
final_asv_table_spp_LMM_1992 <- significant_results_table_spp_LMM_1992[, c("Kingdom", "Phylum", "Class", "Order", "Family", "Genus", "Species", "log2FoldChange", "pvalue", "padj")]
# Rename the columns for better presentation
colnames(final_asv_table_spp_LMM_1992) <- c("Kingdom", "Phylum", "Class", "Order", "Family", "Genus", "Species", "Log2 Fold Change", "P-value", "Adjusted P-value")
subset_final_asv_table_LMM_1992 <- final_asv_table_spp_LMM_1992[1:10, ]
# Get ASV names of differentially abundant ASVs
significant_asv_names_spp_LMM_1992 <- rownames(significant_results_spp_LMM_1992)
# Add the ASV information to the table as the first column
final_asv_table_spp_LMM_1992 <- cbind(ASV = significant_asv_names_spp_LMM_1992, final_asv_table_spp_LMM_1992)
# Display the final table
kable(subset_final_asv_table_LMM_1992, format = "html", align = "c") %>%
kable_styling(bootstrap_options = "striped", full_width = TRUE)
| Kingdom | Phylum | Class | Order | Family | Genus | Species | Log2.Fold.Change | P.value | Adjusted.P.value | |
|---|---|---|---|---|---|---|---|---|---|---|
| ASV7 | Bacteria | Proteobacteria | Alphaproteobacteria | Acetobacterales | Acetobacteraceae | Endobacter | NA | 7.485689 | 0.0000000 | 0.0000011 |
| ASV8 | Bacteria | Proteobacteria | Alphaproteobacteria | Acetobacterales | Acetobacteraceae | Endobacter | NA | 7.613217 | 0.0000000 | 0.0000004 |
| ASV9 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | 1174-901-12 | NA | 5.856533 | 0.0002495 | 0.0015799 |
| ASV10 | Bacteria | Proteobacteria | NA | NA | NA | NA | NA | 8.491029 | 0.0000000 | 0.0000000 |
| ASV14 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | 1174-901-12 | NA | 7.042912 | 0.0000015 | 0.0000291 |
| ASV19 | Bacteria | Proteobacteria | NA | NA | NA | NA | NA | 6.719711 | 0.0000035 | 0.0000528 |
| ASV25 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | 1174-901-12 | NA | 3.813056 | 0.0067123 | 0.0250780 |
| ASV28 | Bacteria | Myxococcota | Myxococcia | Myxococcales | Myxococcaceae | P3OB-42 | NA | 5.722448 | 0.0001316 | 0.0012788 |
| ASV29 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | 1174-901-12 | NA | 5.193758 | 0.0001428 | 0.0012788 |
| ASV33 | Bacteria | Actinobacteriota | Actinobacteria | Kineosporiales | Kineosporiaceae | Quadrisphaera | NA | -3.070385 | 0.0076228 | 0.0263334 |
# Export the table to a CSV file
write.csv(final_asv_table_spp_LMM_1992, file = "final_asv_table_spp_LMM_1992.csv", row.names = FALSE)
# Export the table to a tab-separated TXT file
write.table(final_asv_table_spp_LMM_1992, file = "final_asv_table_spp_LMM_1992.txt", sep = "\t", row.names = FALSE)
#-------------------------------------------------------------------------------
#To see differences b/w Populus and Betula
#-------------------------------------------------------------------------------
# Filter results for the "Betula_populifolia vs Populus_tremuloides" comparison
results_betula_vs_populus_LMM_1992 <- results_diff_abund_LMM_1992[, "log2FoldChange", drop = FALSE]
# Add ASV names to the results
results_betula_vs_populus_LMM_1992$ASV <- rownames(results_diff_abund_LMM_1992)
# Merge with taxonomic information
results_betula_vs_populus_LMM_1992 <- cbind(results_betula_vs_populus_LMM_1992, tax_table(ps_phen_asv_LMM)[rownames(results_diff_abund_LMM_1992), ])
# Select the columns of interest for the final table
final_table_betula_vs_populus_LMM_1992 <- results_betula_vs_populus_LMM_1992[, c("ASV", "Kingdom", "Phylum", "Class", "Order", "Family", "Genus", "Species", "log2FoldChange")]
# Rename the columns for better presentation
colnames(final_table_betula_vs_populus_LMM_1992) <- c("ASV", "Kingdom", "Phylum", "Class", "Order", "Family", "Genus", "Species", "Log2 Fold Change")
subset_bet_vs_pop_LMM_1992 <- final_table_betula_vs_populus_LMM_1992[1:10, ]
# Display the final table
library(knitr)
kable(subset_bet_vs_pop_LMM_1992, format = "html", align = "c") %>%
kable_styling(bootstrap_options = "striped", full_width = TRUE)
| ASV | Kingdom | Phylum | Class | Order | Family | Genus | Species | Log2.Fold.Change | |
|---|---|---|---|---|---|---|---|---|---|
| ASV7 | ASV7 | Bacteria | Proteobacteria | Alphaproteobacteria | Acetobacterales | Acetobacteraceae | Endobacter | NA | 7.4856889 |
| ASV8 | ASV8 | Bacteria | Proteobacteria | Alphaproteobacteria | Acetobacterales | Acetobacteraceae | Endobacter | NA | 7.6132166 |
| ASV9 | ASV9 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | 1174-901-12 | NA | 5.8565333 |
| ASV10 | ASV10 | Bacteria | Proteobacteria | NA | NA | NA | NA | NA | 8.4910291 |
| ASV12 | ASV12 | Bacteria | Firmicutes | Bacilli | Staphylococcales | Staphylococcaceae | Staphylococcus | NA | 2.1763167 |
| ASV13 | ASV13 | Bacteria | Firmicutes | Bacilli | Lactobacillales | Lactobacillaceae | Limosilactobacillus | NA | 0.0000000 |
| ASV14 | ASV14 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | 1174-901-12 | NA | 7.0429124 |
| ASV15 | ASV15 | Bacteria | Firmicutes | Bacilli | Bacillales | Bacillaceae | Bacillus | NA | 0.0000000 |
| ASV16 | ASV16 | Bacteria | Proteobacteria | Gammaproteobacteria | Enterobacterales | Enterobacteriaceae | Escherichia-Shigella | NA | 0.6780711 |
| ASV17 | ASV17 | Bacteria | Proteobacteria | Gammaproteobacteria | Burkholderiales | Oxalobacteraceae | Massilia | NA | 6.4362668 |
# Export the table to a CSV file
write.csv(final_table_betula_vs_populus_LMM_1992, file = "final_table_betula_vs_populus_LMM_1992.csv", row.names = FALSE)
# Export the table to a tab-separated TXT file
write.table(final_table_betula_vs_populus_LMM_1992, file = "final_table_betula_vs_populus_LMM_1992.txt", sep = "\t", row.names = FALSE)
#-------------------------------------------------------------------------------
# Bar Plot
#-------------------------------------------------------------------------------
# Filter significant results (you can adjust the threshold for significance as needed)
significant_results_spp_LMM_1992 <- subset(results_diff_abund_LMM_1992, padj < 0.05)
#significant_results_spp_LMM_1992 <- subset(results_diff_abund_LMM_1992)
# Create a data frame with ASV names and log2 fold change values
data_for_barplot_LMM_1992 <- data.frame(
ASV = rownames(significant_results_spp_LMM_1992),
Log2FoldChange = significant_results_spp_LMM_1992$log2FoldChange
)
data_for_barplot_1992 <- as.data.frame(final_asv_table_spp_LMM_1992)
data_for_barplot_1992$Genus <- ifelse(is.na(data_for_barplot_1992$Genus), "Unknown", data_for_barplot_1992$Genus)
# Add a new column for the absolute values of Log2FoldChange
data_for_barplot_LMM_1992$AbsLog2FoldChange <- abs(data_for_barplot_LMM_1992$Log2FoldChange)
# Sort the data frame by the absolute values of Log2FoldChange in descending order
data_for_barplot_LMM_1992 <- data_for_barplot_LMM_1992[order(-data_for_barplot_LMM_1992$AbsLog2FoldChange), ]
# Select the top 100 ASVs for the bar plot
data_for_barplot_LMM_1992 <- data_for_barplot_LMM_1992[1:29, ]
data_for_barplot_LMM_1992 <- na.omit(data_for_barplot_LMM_1992)
# Create the bar plot
deseq_plot1992_genus <- ggplot(data_for_barplot_1992, aes(x = ASV, y = Log2.Fold.Change, fill = Genus)) +
geom_bar(stat = "identity", color = "black") +
labs(x = "ASV", y = "Log2 Fold Change") +
theme_minimal() +
theme(
axis.title.x = element_text(size = 8),
axis.title.y = element_text(size = 8),
axis.text.x = element_text(angle = -90, hjust = 1, size = 6),
axis.text.y = element_text(size = 6),
legend.title = element_text(size = 12),
legend.text = element_text(size = 12),
panel.border = element_rect(color = "black", size = 1, fill = NA),
legend.position = "none",
axis.ticks = element_line(color = "black")
) +
scale_fill_manual(values = genus_colors)
deseq_plot1992_genus
ggsave("deseq_plot1992_genus.png", deseq_plot1992_genus, width=12, height=8)
#-------------------------------------------------------------------------------
# Bubble Plot
#-------------------------------------------------------------------------------
# Create the bubble plot
deseq_plot1992_genus2 <- ggplot(
data_for_barplot_1992,
aes(
x = fct_reorder(ASV, Log2.Fold.Change, .fun = ~median(., na.rm = TRUE), .desc = TRUE),
y = Log2.Fold.Change,
fill = Genus
)
) +
geom_hline(yintercept = 0, linewidth = 0.4, color = "grey60") +
geom_point(aes(size = -log10(Adjusted.P.value)), shape = 21, stroke = 0.6, color = "black") + # bubble/circle points
# scale_x_discrete(expand = expansion(mult = c(0.04, 0.02))) +
scale_size_area(
name = expression(-log[10]("adj p")),
max_size = 5,
limits = c(0, NA),
guide = "none"
) +
labs(x = "ASV", y = "Log2 Fold Change") +
theme_minimal() +
theme(
axis.title.x = element_text(size = 6),
axis.title.y = element_text(size = 6),
axis.text.x = element_text(angle = -90, vjust = 0.5, size = 6),
axis.text.y = element_text(size = 6),
legend.title = element_text(size = 6),
legend.text = element_text(size = 5),
legend.box.margin = margin(0, 0, 0, -12, unit = "pt"),
panel.border = element_rect(color = "black", size = 1, fill = NA),
axis.ticks = element_line(color = "black"),
legend.position = "none"
) +
guides(fill = guide_legend(override.aes = list(size = 2), keyheight = 0.5, keywidth = 0.5, ncol = 2)) +
scale_fill_manual(values = genus_colors)
deseq_plot1992_genus2
deseq_plot1992_phylum <- ggplot(data_for_barplot_1992, aes(x = ASV, y = Log2.Fold.Change, fill = Phylum)) +
geom_bar(stat = "identity", color = "black") +
labs(x = "ASV", y = "Log2 Fold Change") +
theme_minimal() +
theme(
axis.title.x = element_text(size = 8),
axis.title.y = element_text(size = 8),
axis.text.x = element_text(angle = -90, hjust = 1, size = 6),
axis.text.y = element_text(size = 6),
legend.title = element_text(size = 12),
legend.text = element_text(size = 12),
panel.border = element_rect(color = "black", size = 1, fill = NA),
legend.position = "none",
axis.ticks = element_line(color = "black")
) +
scale_fill_manual(values = phylum_colors)
deseq_plot1992_phylum
#ggsave("deseq_plot1992_phylum.png", deseq_plot1992_phylum, width=12, height=8)
#-------------------------------------------------------------------------------
# Bubble Plot
#-------------------------------------------------------------------------------
# Create the bubble plot
deseq_plot1992_phylum2 <- ggplot(
data_for_barplot_1992,
aes(
x = fct_reorder(ASV, Log2.Fold.Change, .fun = ~median(., na.rm = TRUE), .desc = TRUE),
y = Log2.Fold.Change,
fill = Phylum
)
) +
geom_hline(yintercept = 0, linewidth = 0.4, color = "grey60") +
geom_point(aes(size = -log10(Adjusted.P.value)), shape = 21, stroke = 0.6, color = "black") + # bubble/circle points
scale_size_continuous(
name = expression(-log[10]("adj p")),
# range = c(2, 4), # make min larger & max bigger; preserves proportions
guide = "none"
) +
labs(x = "ASV", y = "Log2 Fold Change") +
theme_minimal() +
theme(
axis.title.x = element_text(size = 6),
axis.title.y = element_text(size = 6),
axis.text.x = element_text(angle = -90, vjust = 0.5, size = 6),
axis.text.y = element_text(size = 6),
legend.title = element_text(size = 6),
legend.text = element_text(size = 5),
legend.box.margin = margin(0, 0, 0, -12, unit = "pt"),
panel.border = element_rect(color = "black", size = 1, fill = NA),
axis.ticks = element_line(color = "black")
) +
guides(fill = guide_legend(keyheight = 0.5, keywidth = 0.5)) +
scale_fill_manual(values = phylum_colors)
deseq_plot1992_phylum2
#-------------------------------------------------------------------------------
## GDD 2140
#-------------------------------------------------------------------------------
# Get differential abundance results for tree species
results_diff_abund_LMM_2140 <- results(dds_2140, contrast=c("Species", "Betula_populifolia", "Populus_tremuloides"))
# Filter significant ASVs for species comparison
#significant_asvs_LMM_2140 <- subset(results_diff_abund_LMM_2140, padj < 0.05)
significant_asvs_LMM_2140 <- subset(results_diff_abund_LMM_2140)
head(significant_asvs_LMM_2140)
## log2 fold change (MLE): Species Betula_populifolia vs Populus_tremuloides
## Wald test p-value: Species Betula_populifolia vs Populus_tremuloides
## DataFrame with 6 rows and 6 columns
## baseMean log2FoldChange lfcSE stat pvalue padj
## <numeric> <numeric> <numeric> <numeric> <numeric> <numeric>
## ASV7 392.2 9.61359e+00 1.191633 8.06758e+00 7.17072e-16 1.03258e-13
## ASV8 186.1 6.19848e+00 1.337457 4.63452e+00 3.57760e-06 4.68340e-05
## ASV9 281.5 7.86777e+00 1.336519 5.88676e+00 3.93832e-09 1.89039e-07
## ASV10 172.1 8.42289e+00 1.334185 6.31313e+00 2.73443e-10 1.96879e-08
## ASV12 8.6 -1.72247e+00 1.060457 -1.62427e+00 1.04319e-01 1.22129e-01
## ASV13 1.0 -2.04641e-16 0.954646 -2.14364e-16 1.00000e+00 NA
#-------------------------------------------------------------------------------
#ASV Heatmap:
#-------------------------------------------------------------------------------
# Assuming 'dds' is your DESeq2 object and 'top_asvs' is the data frame containing top ASVs
top_asv_names_LMM_2140 <- rownames(significant_asvs_LMM_2140)
top_asv_counts_LMM_2140 <- counts(dds_2140)[top_asv_names_LMM_2140, ]
# Create the heatmap
heatmap(as.matrix(top_asv_counts_LMM_2140), scale = "row", Rowv = FALSE, Colv = FALSE, col = viridis::viridis(100))
#-------------------------------------------------------------------------------
# Top ASVs for Species:
#-------------------------------------------------------------------------------
# Select the columns you want in the table
top_asv_table_spp_LMM_2140 <- significant_asvs_LMM_2140[, c("baseMean", "log2FoldChange", "lfcSE", "stat", "pvalue", "padj")]
# Optionally, you can add the taxonomic information if available
# Assuming you have a taxonomic table named 'tax_table' with a column 'Genus'
top_asv_table_spp_LMM_2140$Genus <- taxa_rdp[rownames(top_asv_table_spp_LMM_2140), "Genus"]
# Print the table
print(top_asv_table_spp_LMM_2140)
## log2 fold change (MLE): Species Betula_populifolia vs Populus_tremuloides
## Wald test p-value: Species Betula_populifolia vs Populus_tremuloides
## DataFrame with 1732 rows and 7 columns
## baseMean log2FoldChange lfcSE stat pvalue padj
## <numeric> <numeric> <numeric> <numeric> <numeric> <numeric>
## ASV7 392.2 9.61359 1.19163 8.06758 7.17072e-16 1.03258e-13
## ASV8 186.1 6.19848 1.33746 4.63452 3.57760e-06 4.68340e-05
## ASV9 281.5 7.86777 1.33652 5.88676 3.93832e-09 1.89039e-07
## ASV10 172.1 8.42289 1.33418 6.31313 2.73443e-10 1.96879e-08
## ASV12 8.6 -1.72247 1.06046 -1.62427 1.04319e-01 1.22129e-01
## ... ... ... ... ... ... ...
## ASV1786 1.0 -2.04641e-16 0.954646 -2.14364e-16 1.000000 NA
## ASV1787 1.0 -2.04641e-16 0.954646 -2.14364e-16 1.000000 NA
## ASV1788 1.0 -2.04641e-16 0.954646 -2.14364e-16 1.000000 NA
## ASV1789 1.0 -2.04641e-16 0.954646 -2.14364e-16 1.000000 NA
## ASV1790 1.2 -4.85426e-01 0.915947 -5.29972e-01 0.596131 NA
## Genus
## <character>
## ASV7 Endobacter
## ASV8 Endobacter
## ASV9 1174-901-12
## ASV10 NA
## ASV12 Staphylococcus
## ... ...
## ASV1786 NA
## ASV1787 Conexibacter
## ASV1788 Methylobacterium-Met..
## ASV1789 NA
## ASV1790 NA
head(top_asv_table_spp_LMM_2140)
## log2 fold change (MLE): Species Betula_populifolia vs Populus_tremuloides
## Wald test p-value: Species Betula_populifolia vs Populus_tremuloides
## DataFrame with 6 rows and 7 columns
## baseMean log2FoldChange lfcSE stat pvalue padj
## <numeric> <numeric> <numeric> <numeric> <numeric> <numeric>
## ASV7 392.2 9.61359e+00 1.191633 8.06758e+00 7.17072e-16 1.03258e-13
## ASV8 186.1 6.19848e+00 1.337457 4.63452e+00 3.57760e-06 4.68340e-05
## ASV9 281.5 7.86777e+00 1.336519 5.88676e+00 3.93832e-09 1.89039e-07
## ASV10 172.1 8.42289e+00 1.334185 6.31313e+00 2.73443e-10 1.96879e-08
## ASV12 8.6 -1.72247e+00 1.060457 -1.62427e+00 1.04319e-01 1.22129e-01
## ASV13 1.0 -2.04641e-16 0.954646 -2.14364e-16 1.00000e+00 NA
## Genus
## <character>
## ASV7 Endobacter
## ASV8 Endobacter
## ASV9 1174-901-12
## ASV10 NA
## ASV12 Staphylococcus
## ASV13 Limosilactobacillus
# Export the table to a CSV file
write.csv(top_asv_table_spp_LMM_2140, file = "top_asv_table_LMM_2140.csv", row.names = FALSE)
#-------------------------------------------------------------------------------
# Making Kable Table
#-------------------------------------------------------------------------------
# Filter significant results (you can adjust the threshold for significance as needed)
significant_results_spp_LMM_2140 <- subset(results_diff_abund_LMM_2140, padj < 0.05)
#significant_results_spp_LMM_2140 <- subset(results_diff_abund_LMM_2140)
# Get ASV names of differentially abundant ASVs
significant_asv_names_spp_LMM_2140 <- rownames(significant_results_spp_LMM_2140)
# Get the taxonomic information for the significant ASVs
significant_asv_tax_spp_LMM_2140 <- tax_table(ps_phen_asv_LMM)[significant_asv_names_spp_LMM_2140, ]
# Merge the results with taxonomic information
significant_results_table_spp_LMM_2140 <- cbind(significant_asv_tax_spp_LMM_2140, significant_results_spp_LMM_2140)
# Select columns of interest for the final table
final_asv_table_spp_LMM_2140 <- significant_results_table_spp_LMM_2140[, c("Kingdom", "Phylum", "Class", "Order", "Family", "Genus", "Species", "log2FoldChange", "pvalue", "padj")]
# Rename the columns for better presentation
colnames(final_asv_table_spp_LMM_2140) <- c("Kingdom", "Phylum", "Class", "Order", "Family", "Genus", "Species", "Log2 Fold Change", "P-value", "Adjusted P-value")
subset_final_asv_table_LMM_2140 <- final_asv_table_spp_LMM_2140[1:10, ]
# Get ASV names of differentially abundant ASVs
significant_asv_names_spp_LMM_2140 <- rownames(significant_results_spp_LMM_2140)
# Add the ASV information to the table as the first column
final_asv_table_spp_LMM_2140 <- cbind(ASV = significant_asv_names_spp_LMM_2140, final_asv_table_spp_LMM_2140)
# Display the final table
kable(subset_final_asv_table_LMM_2140, format = "html", align = "c") %>%
kable_styling(bootstrap_options = "striped", full_width = TRUE)
| Kingdom | Phylum | Class | Order | Family | Genus | Species | Log2.Fold.Change | P.value | Adjusted.P.value | |
|---|---|---|---|---|---|---|---|---|---|---|
| ASV7 | Bacteria | Proteobacteria | Alphaproteobacteria | Acetobacterales | Acetobacteraceae | Endobacter | NA | 9.613587 | 0.00e+00 | 0.0000000 |
| ASV8 | Bacteria | Proteobacteria | Alphaproteobacteria | Acetobacterales | Acetobacteraceae | Endobacter | NA | 6.198476 | 3.60e-06 | 0.0000468 |
| ASV9 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | 1174-901-12 | NA | 7.867772 | 0.00e+00 | 0.0000002 |
| ASV10 | Bacteria | Proteobacteria | NA | NA | NA | NA | NA | 8.422885 | 0.00e+00 | 0.0000000 |
| ASV14 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | 1174-901-12 | NA | 6.221573 | 3.00e-07 | 0.0000089 |
| ASV19 | Bacteria | Proteobacteria | NA | NA | NA | NA | NA | 7.850467 | 4.30e-06 | 0.0000521 |
| ASV25 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | 1174-901-12 | NA | 6.872808 | 2.90e-06 | 0.0000418 |
| ASV29 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | 1174-901-12 | NA | 6.995465 | 9.00e-07 | 0.0000214 |
| ASV33 | Bacteria | Actinobacteriota | Actinobacteria | Kineosporiales | Kineosporiaceae | Quadrisphaera | NA | -5.812492 | 1.00e-07 | 0.0000026 |
| ASV35 | Bacteria | NA | NA | NA | NA | NA | NA | 5.232648 | 7.11e-05 | 0.0006826 |
# Export the table to a CSV file
write.csv(final_asv_table_spp_LMM_2140, file = "final_asv_table_spp_LMM_2140.csv", row.names = FALSE)
# Export the table to a tab-separated TXT file
write.table(final_asv_table_spp_LMM_2140, file = "final_asv_table_spp_LMM_2140.txt", sep = "\t", row.names = FALSE)
#-------------------------------------------------------------------------------
#To see differences b/w Populus and Betula
#-------------------------------------------------------------------------------
# Filter results for the "Betula_populifolia vs Populus_tremuloides" comparison
results_betula_vs_populus_LMM_2140 <- results_diff_abund_LMM_2140[, "log2FoldChange", drop = FALSE]
# Add ASV names to the results
results_betula_vs_populus_LMM_2140$ASV <- rownames(results_diff_abund_LMM_2140)
# Merge with taxonomic information
results_betula_vs_populus_LMM_2140 <- cbind(results_betula_vs_populus_LMM_2140, tax_table(ps_phen_asv_LMM)[rownames(results_diff_abund_LMM_2140), ])
# Select the columns of interest for the final table
final_table_betula_vs_populus_LMM_2140 <- results_betula_vs_populus_LMM_2140[, c("ASV", "Kingdom", "Phylum", "Class", "Order", "Family", "Genus", "Species", "log2FoldChange")]
# Rename the columns for better presentation
colnames(final_table_betula_vs_populus_LMM_2140) <- c("ASV", "Kingdom", "Phylum", "Class", "Order", "Family", "Genus", "Species", "Log2 Fold Change")
subset_bet_vs_pop_LMM_2140 <- final_table_betula_vs_populus_LMM_2140[1:10, ]
# Display the final table
library(knitr)
kable(subset_bet_vs_pop_LMM_2140, format = "html", align = "c") %>%
kable_styling(bootstrap_options = "striped", full_width = TRUE)
| ASV | Kingdom | Phylum | Class | Order | Family | Genus | Species | Log2.Fold.Change | |
|---|---|---|---|---|---|---|---|---|---|
| ASV7 | ASV7 | Bacteria | Proteobacteria | Alphaproteobacteria | Acetobacterales | Acetobacteraceae | Endobacter | NA | 9.613587 |
| ASV8 | ASV8 | Bacteria | Proteobacteria | Alphaproteobacteria | Acetobacterales | Acetobacteraceae | Endobacter | NA | 6.198476 |
| ASV9 | ASV9 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | 1174-901-12 | NA | 7.867772 |
| ASV10 | ASV10 | Bacteria | Proteobacteria | NA | NA | NA | NA | NA | 8.422885 |
| ASV12 | ASV12 | Bacteria | Firmicutes | Bacilli | Staphylococcales | Staphylococcaceae | Staphylococcus | NA | -1.722465 |
| ASV13 | ASV13 | Bacteria | Firmicutes | Bacilli | Lactobacillales | Lactobacillaceae | Limosilactobacillus | NA | 0.000000 |
| ASV14 | ASV14 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | 1174-901-12 | NA | 6.221573 |
| ASV15 | ASV15 | Bacteria | Firmicutes | Bacilli | Bacillales | Bacillaceae | Bacillus | NA | 0.000000 |
| ASV16 | ASV16 | Bacteria | Proteobacteria | Gammaproteobacteria | Enterobacterales | Enterobacteriaceae | Escherichia-Shigella | NA | 0.000000 |
| ASV17 | ASV17 | Bacteria | Proteobacteria | Gammaproteobacteria | Burkholderiales | Oxalobacteraceae | Massilia | NA | 6.778170 |
# Export the table to a CSV file
write.csv(final_table_betula_vs_populus_LMM_2140, file = "final_table_betula_vs_populus_LMM_2140.csv", row.names = FALSE)
# Export the table to a tab-separated TXT file
write.table(final_table_betula_vs_populus_LMM_2140, file = "final_table_betula_vs_populus_LMM_2140.txt", sep = "\t", row.names = FALSE)
#-------------------------------------------------------------------------------
# Bar Plot
#-------------------------------------------------------------------------------
# Filter significant results (you can adjust the threshold for significance as needed)
significant_results_spp_LMM_2140 <- subset(results_diff_abund_LMM_2140, padj < 0.05)
#significant_results_spp_LMM_2140 <- subset(results_diff_abund_LMM_2140)
# Create a data frame with ASV names and log2 fold change values
data_for_barplot_LMM_2140 <- data.frame(
ASV = rownames(significant_results_spp_LMM_2140),
Log2FoldChange = significant_results_spp_LMM_2140$log2FoldChange
)
data_for_barplot_2140 <- as.data.frame(final_asv_table_spp_LMM_2140)
data_for_barplot_2140$Genus <- ifelse(is.na(data_for_barplot_2140$Genus), "Unknown", data_for_barplot_2140$Genus)
# Add a new column for the absolute values of Log2FoldChange
data_for_barplot_LMM_2140$AbsLog2FoldChange <- abs(data_for_barplot_LMM_2140$Log2FoldChange)
# Sort the data frame by the absolute values of Log2FoldChange in descending order
data_for_barplot_LMM_2140 <- data_for_barplot_LMM_2140[order(-data_for_barplot_LMM_2140$AbsLog2FoldChange), ]
# Select the top 100 ASVs for the bar plot
data_for_barplot_LMM_2140 <- data_for_barplot_LMM_2140[1:45, ]
data_for_barplot_LMM_2140 <- na.omit(data_for_barplot_LMM_2140)
# Create the bar plot
deseq_plot2140_genus <- ggplot(data_for_barplot_2140, aes(x = ASV, y = Log2.Fold.Change, fill = Genus)) +
geom_bar(stat = "identity", color = "black") +
labs(x = "ASV", y = "Log2 Fold Change") +
theme_minimal() +
theme(
axis.title.x = element_text(size = 8),
axis.title.y = element_text(size = 8),
axis.text.x = element_text(angle = -90, hjust = 1, size = 6),
axis.text.y = element_text(size = 6),
legend.title = element_text(size = 12),
legend.text = element_text(size = 12),
panel.border = element_rect(color = "black", size = 1, fill = NA),
legend.position = "none",
axis.ticks = element_line(color = "black")
) +
scale_fill_manual(values = genus_colors)
deseq_plot2140_genus
ggsave("deseq_plot2140_genus.png", deseq_plot2140_genus, width=12, height=8)
#-------------------------------------------------------------------------------
# Bubble Plot
#-------------------------------------------------------------------------------
# Create the bubble plot
deseq_plot2140_genus2 <- ggplot(
data_for_barplot_2140,
aes(
x = fct_reorder(ASV, Log2.Fold.Change, .fun = ~median(., na.rm = TRUE), .desc = TRUE),
y = Log2.Fold.Change,
fill = Genus
)
) +
geom_hline(yintercept = 0, linewidth = 0.4, color = "grey60") +
geom_point(aes(size = -log10(Adjusted.P.value)), shape = 21, stroke = 0.6, color = "black") + # bubble/circle points
# scale_x_discrete(expand = expansion(mult = c(0.04, 0.02))) +
scale_size_area(
name = expression(-log[10]("adj p")),
max_size = 5,
limits = c(0, NA),
guide = "none"
) +
labs(x = "ASV", y = "Log2 Fold Change") +
theme_minimal() +
theme(
axis.title.x = element_text(size = 6),
axis.title.y = element_text(size = 6),
axis.text.x = element_text(angle = -90, vjust = 0.5, size = 6),
axis.text.y = element_text(size = 6),
legend.title = element_text(size = 6),
legend.text = element_text(size = 5),
legend.box.margin = margin(0, 0, 0, -12, unit = "pt"),
panel.border = element_rect(color = "black", size = 1, fill = NA),
axis.ticks = element_line(color = "black"),
legend.position = "none"
) +
guides(fill = guide_legend(override.aes = list(size = 2), keyheight = 0.5, keywidth = 0.5, ncol = 2)) +
scale_fill_manual(
values = genus_colors,
labels = function(x) {
x <- str_replace(x, "Methylobacterium-Methylorubrum", "Methylobacterium-\nMethylorubrum")
x <- str_replace(x, "Candidatus Ovatusbacter", "Candidatus\nOvatusbacter")
x
}
)
deseq_plot2140_genus2
# Create the bar plot
deseq_plot2140_phylum <- ggplot(data_for_barplot_2140, aes(x = ASV, y = Log2.Fold.Change, fill = Phylum)) +
geom_bar(stat = "identity", color = "black") +
labs(x = "ASV", y = "Log2 Fold Change") +
theme_minimal() +
theme(
axis.title.x = element_text(size = 8),
axis.title.y = element_text(size = 8),
axis.text.x = element_text(angle = -90, hjust = 1, size = 6),
axis.text.y = element_text(size = 6),
legend.title = element_text(size = 12),
legend.text = element_text(size = 12),
panel.border = element_rect(color = "black", size = 1, fill = NA),
legend.position = "none",
axis.ticks = element_line(color = "black")
) +
scale_fill_manual(values = phylum_colors)
deseq_plot2140_phylum
#ggsave("deseq_plot2140_phylum.png", deseq_plot2140_phylum, width=12, height=8)
#-------------------------------------------------------------------------------
# Bubble Plot
#-------------------------------------------------------------------------------
# Create the bubble plot
deseq_plot2140_phylum2 <- ggplot(
data_for_barplot_2140,
aes(
x = fct_reorder(ASV, Log2.Fold.Change, .fun = ~median(., na.rm = TRUE), .desc = TRUE),
y = Log2.Fold.Change,
fill = Phylum
)
) +
geom_hline(yintercept = 0, linewidth = 0.4, color = "grey60") +
geom_point(aes(size = -log10(Adjusted.P.value)), shape = 21, stroke = 0.6, color = "black") + # bubble/circle points
scale_size_continuous(
name = expression(-log[10]("adj p")),
# range = c(2, 4), # make min larger & max bigger; preserves proportions
guide = "none"
) +
labs(x = "ASV", y = "Log2 Fold Change") +
theme_minimal() +
theme(
axis.title.x = element_text(size = 6),
axis.title.y = element_text(size = 6),
axis.text.x = element_text(angle = -90, vjust = 0.5, size = 6),
axis.text.y = element_text(size = 6),
legend.title = element_text(size = 6),
legend.text = element_text(size = 5),
legend.box.margin = margin(0, 0, 0, -12, unit = "pt"),
panel.border = element_rect(color = "black", size = 1, fill = NA),
axis.ticks = element_line(color = "black")
) +
guides(fill = guide_legend(keyheight = 0.5, keywidth = 0.5)) +
scale_fill_manual(values = phylum_colors)
deseq_plot2140_phylum2
library(gridExtra)
# Extract the legend
get_legend <- function(myggplot) {
tmp <- ggplot_gtable(ggplot_build(myggplot))
legend <- tmp$grobs[[which(sapply(tmp$grobs, function(x) x$name) == "guide-box")]]
return(legend)
}
legend_gdd2140_phylum <- get_legend(deseq_plot2140_phylum)
# Modify the grob's size (scaling the legend up by a factor of 3)
legend_gdd2140_phylum_enlarged <- editGrob(legend_gdd2140_phylum, vp = viewport(width = 9,
height = 9)) # Scaling factor of 3
# Use the grid package to save the legend separately
library(grid)
# Save the legend to a PNG file
png("deseq_plot2140_legend.jpg", width = 3200, height = 2400, res = 300)
grid.draw(legend_gdd2140_phylum) # Draw the legend onto the file
dev.off() # Close the graphics device
#-------------------------------------------------------------------------------
## GDD 2219
#-------------------------------------------------------------------------------
# Get differential abundance results for tree species
results_diff_abund_LMM_2219 <- results(dds_2219, contrast=c("Species", "Betula_populifolia", "Populus_tremuloides"))
# Filter significant ASVs for species comparison
#significant_asvs_LMM_2219 <- subset(results_diff_abund_LMM_2219, padj < 0.05)
significant_asvs_LMM_2219 <- subset(results_diff_abund_LMM_2219)
head(significant_asvs_LMM_2219)
## log2 fold change (MLE): Species Betula_populifolia vs Populus_tremuloides
## Wald test p-value: Species Betula_populifolia vs Populus_tremuloides
## DataFrame with 6 rows and 6 columns
## baseMean log2FoldChange lfcSE stat pvalue padj
## <numeric> <numeric> <numeric> <numeric> <numeric> <numeric>
## ASV7 817.3 1.06738e+01 1.076134 9.91867e+00 3.45313e-23 2.76250e-21
## ASV8 631.2 1.03008e+01 1.037466 9.92880e+00 3.11985e-23 2.76250e-21
## ASV9 394.6 6.80402e+00 1.224674 5.55578e+00 2.76369e-08 1.10548e-06
## ASV10 82.7 7.36105e+00 1.362842 5.40125e+00 6.61788e-08 2.11772e-06
## ASV12 35.1 -2.49125e+00 1.174891 -2.12041e+00 3.39718e-02 9.61354e-02
## ASV13 1.0 -2.07448e-16 0.960862 -2.15898e-16 1.00000e+00 NA
#-------------------------------------------------------------------------------
#ASV Heatmap:
#-------------------------------------------------------------------------------
# Assuming 'dds' is your DESeq2 object and 'top_asvs' is the data frame containing top ASVs
top_asv_names_LMM_2219 <- rownames(significant_asvs_LMM_2219)
top_asv_counts_LMM_2219 <- counts(dds_2219)[top_asv_names_LMM_2219, ]
# Create the heatmap
heatmap(as.matrix(top_asv_counts_LMM_2219), scale = "row", Rowv = FALSE, Colv = FALSE, col = viridis::viridis(100))
#-------------------------------------------------------------------------------
# Top ASVs for Species:
#-------------------------------------------------------------------------------
# Select the columns you want in the table
top_asv_table_spp_LMM_2219 <- significant_asvs_LMM_2219[, c("baseMean", "log2FoldChange", "lfcSE", "stat", "pvalue", "padj")]
# Optionally, you can add the taxonomic information if available
# Assuming you have a taxonomic table named 'tax_table' with a column 'Genus'
top_asv_table_spp_LMM_2219$Genus <- taxa_rdp[rownames(top_asv_table_spp_LMM_2219), "Genus"]
# Print the table
print(top_asv_table_spp_LMM_2219)
## log2 fold change (MLE): Species Betula_populifolia vs Populus_tremuloides
## Wald test p-value: Species Betula_populifolia vs Populus_tremuloides
## DataFrame with 1732 rows and 7 columns
## baseMean log2FoldChange lfcSE stat pvalue padj
## <numeric> <numeric> <numeric> <numeric> <numeric> <numeric>
## ASV7 817.3 10.67382 1.07613 9.91867 3.45313e-23 2.76250e-21
## ASV8 631.2 10.30080 1.03747 9.92880 3.11985e-23 2.76250e-21
## ASV9 394.6 6.80402 1.22467 5.55578 2.76369e-08 1.10548e-06
## ASV10 82.7 7.36105 1.36284 5.40125 6.61788e-08 2.11772e-06
## ASV12 35.1 -2.49125 1.17489 -2.12041 3.39718e-02 9.61354e-02
## ... ... ... ... ... ... ...
## ASV1786 1 -2.07448e-16 0.960862 -2.15898e-16 1 NA
## ASV1787 1 -2.07448e-16 0.960862 -2.15898e-16 1 NA
## ASV1788 1 -2.07448e-16 0.960862 -2.15898e-16 1 NA
## ASV1789 1 -2.07448e-16 0.960862 -2.15898e-16 1 NA
## ASV1790 1 -2.07448e-16 0.960862 -2.15898e-16 1 NA
## Genus
## <character>
## ASV7 Endobacter
## ASV8 Endobacter
## ASV9 1174-901-12
## ASV10 NA
## ASV12 Staphylococcus
## ... ...
## ASV1786 NA
## ASV1787 Conexibacter
## ASV1788 Methylobacterium-Met..
## ASV1789 NA
## ASV1790 NA
head(top_asv_table_spp_LMM_2219)
## log2 fold change (MLE): Species Betula_populifolia vs Populus_tremuloides
## Wald test p-value: Species Betula_populifolia vs Populus_tremuloides
## DataFrame with 6 rows and 7 columns
## baseMean log2FoldChange lfcSE stat pvalue padj
## <numeric> <numeric> <numeric> <numeric> <numeric> <numeric>
## ASV7 817.3 1.06738e+01 1.076134 9.91867e+00 3.45313e-23 2.76250e-21
## ASV8 631.2 1.03008e+01 1.037466 9.92880e+00 3.11985e-23 2.76250e-21
## ASV9 394.6 6.80402e+00 1.224674 5.55578e+00 2.76369e-08 1.10548e-06
## ASV10 82.7 7.36105e+00 1.362842 5.40125e+00 6.61788e-08 2.11772e-06
## ASV12 35.1 -2.49125e+00 1.174891 -2.12041e+00 3.39718e-02 9.61354e-02
## ASV13 1.0 -2.07448e-16 0.960862 -2.15898e-16 1.00000e+00 NA
## Genus
## <character>
## ASV7 Endobacter
## ASV8 Endobacter
## ASV9 1174-901-12
## ASV10 NA
## ASV12 Staphylococcus
## ASV13 Limosilactobacillus
# Export the table to a CSV file
write.csv(top_asv_table_spp_LMM_2219, file = "top_asv_table_LMM_2219.csv", row.names = FALSE)
#-------------------------------------------------------------------------------
# Making Kable Table
#-------------------------------------------------------------------------------
# Filter significant results (you can adjust the threshold for significance as needed)
significant_results_spp_LMM_2219 <- subset(results_diff_abund_LMM_2219, padj < 0.05)
#significant_results_spp_LMM_2219 <- subset(results_diff_abund_LMM_2219)
# Get ASV names of differentially abundant ASVs
significant_asv_names_spp_LMM_2219 <- rownames(significant_results_spp_LMM_2219)
# Get the taxonomic information for the significant ASVs
significant_asv_tax_spp_LMM_2219 <- tax_table(ps_phen_asv_LMM)[significant_asv_names_spp_LMM_2219, ]
# Merge the results with taxonomic information
significant_results_table_spp_LMM_2219 <- cbind(significant_asv_tax_spp_LMM_2219, significant_results_spp_LMM_2219)
# Select columns of interest for the final table
final_asv_table_spp_LMM_2219 <- significant_results_table_spp_LMM_2219[, c("Kingdom", "Phylum", "Class", "Order", "Family", "Genus", "Species", "log2FoldChange", "pvalue", "padj")]
# Rename the columns for better presentation
colnames(final_asv_table_spp_LMM_2219) <- c("Kingdom", "Phylum", "Class", "Order", "Family", "Genus", "Species", "Log2 Fold Change", "P-value", "Adjusted P-value")
subset_final_asv_table_LMM_2219 <- final_asv_table_spp_LMM_2219[1:10, ]
# Get ASV names of differentially abundant ASVs
significant_asv_names_spp_LMM_2219 <- rownames(significant_results_spp_LMM_2219)
# Add the ASV information to the table as the first column
final_asv_table_spp_LMM_2219 <- cbind(ASV = significant_asv_names_spp_LMM_2219, final_asv_table_spp_LMM_2219)
# Display the final table
kable(subset_final_asv_table_LMM_2219, format = "html", align = "c") %>%
kable_styling(bootstrap_options = "striped", full_width = TRUE)
| Kingdom | Phylum | Class | Order | Family | Genus | Species | Log2.Fold.Change | P.value | Adjusted.P.value | |
|---|---|---|---|---|---|---|---|---|---|---|
| ASV7 | Bacteria | Proteobacteria | Alphaproteobacteria | Acetobacterales | Acetobacteraceae | Endobacter | NA | 10.673823 | 0.00e+00 | 0.0000000 |
| ASV8 | Bacteria | Proteobacteria | Alphaproteobacteria | Acetobacterales | Acetobacteraceae | Endobacter | NA | 10.300796 | 0.00e+00 | 0.0000000 |
| ASV9 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | 1174-901-12 | NA | 6.804022 | 0.00e+00 | 0.0000011 |
| ASV10 | Bacteria | Proteobacteria | NA | NA | NA | NA | NA | 7.361047 | 1.00e-07 | 0.0000021 |
| ASV14 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | 1174-901-12 | NA | 8.420367 | 0.00e+00 | 0.0000000 |
| ASV19 | Bacteria | Proteobacteria | NA | NA | NA | NA | NA | 6.053095 | 1.75e-05 | 0.0003103 |
| ASV25 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | 1174-901-12 | NA | 6.722444 | 1.04e-05 | 0.0002075 |
| ASV28 | Bacteria | Myxococcota | Myxococcia | Myxococcales | Myxococcaceae | P3OB-42 | NA | 5.902059 | 1.00e-05 | 0.0002075 |
| ASV29 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | 1174-901-12 | NA | 5.602870 | 4.52e-05 | 0.0006024 |
| ASV33 | Bacteria | Actinobacteriota | Actinobacteria | Kineosporiales | Kineosporiaceae | Quadrisphaera | NA | -5.255491 | 9.71e-05 | 0.0011103 |
# Export the table to a CSV file
write.csv(final_asv_table_spp_LMM_2219, file = "final_asv_table_spp_LMM_2219.csv", row.names = FALSE)
# Export the table to a tab-separated TXT file
write.table(final_asv_table_spp_LMM_2219, file = "final_asv_table_spp_LMM_2219.txt", sep = "\t", row.names = FALSE)
#-------------------------------------------------------------------------------
#To see differences b/w Populus and Betula
#-------------------------------------------------------------------------------
# Filter results for the "Betula_populifolia vs Populus_tremuloides" comparison
results_betula_vs_populus_LMM_2219 <- results_diff_abund_LMM_2219[, "log2FoldChange", drop = FALSE]
# Add ASV names to the results
results_betula_vs_populus_LMM_2219$ASV <- rownames(results_diff_abund_LMM_2219)
# Merge with taxonomic information
results_betula_vs_populus_LMM_2219 <- cbind(results_betula_vs_populus_LMM_2219, tax_table(ps_phen_asv_LMM)[rownames(results_diff_abund_LMM_2219), ])
# Select the columns of interest for the final table
final_table_betula_vs_populus_LMM_2219 <- results_betula_vs_populus_LMM_2219[, c("ASV", "Kingdom", "Phylum", "Class", "Order", "Family", "Genus", "Species", "log2FoldChange")]
# Rename the columns for better presentation
colnames(final_table_betula_vs_populus_LMM_2219) <- c("ASV", "Kingdom", "Phylum", "Class", "Order", "Family", "Genus", "Species", "Log2 Fold Change")
subset_bet_vs_pop_LMM_2219 <- final_table_betula_vs_populus_LMM_2219[1:10, ]
# Display the final table
library(knitr)
kable(subset_bet_vs_pop_LMM_2219, format = "html", align = "c") %>%
kable_styling(bootstrap_options = "striped", full_width = TRUE)
| ASV | Kingdom | Phylum | Class | Order | Family | Genus | Species | Log2.Fold.Change | |
|---|---|---|---|---|---|---|---|---|---|
| ASV7 | ASV7 | Bacteria | Proteobacteria | Alphaproteobacteria | Acetobacterales | Acetobacteraceae | Endobacter | NA | 10.673823 |
| ASV8 | ASV8 | Bacteria | Proteobacteria | Alphaproteobacteria | Acetobacterales | Acetobacteraceae | Endobacter | NA | 10.300796 |
| ASV9 | ASV9 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | 1174-901-12 | NA | 6.804022 |
| ASV10 | ASV10 | Bacteria | Proteobacteria | NA | NA | NA | NA | NA | 7.361047 |
| ASV12 | ASV12 | Bacteria | Firmicutes | Bacilli | Staphylococcales | Staphylococcaceae | Staphylococcus | NA | -2.491247 |
| ASV13 | ASV13 | Bacteria | Firmicutes | Bacilli | Lactobacillales | Lactobacillaceae | Limosilactobacillus | NA | 0.000000 |
| ASV14 | ASV14 | Bacteria | Proteobacteria | Alphaproteobacteria | Rhizobiales | Beijerinckiaceae | 1174-901-12 | NA | 8.420367 |
| ASV15 | ASV15 | Bacteria | Firmicutes | Bacilli | Bacillales | Bacillaceae | Bacillus | NA | 0.000000 |
| ASV16 | ASV16 | Bacteria | Proteobacteria | Gammaproteobacteria | Enterobacterales | Enterobacteriaceae | Escherichia-Shigella | NA | 0.000000 |
| ASV17 | ASV17 | Bacteria | Proteobacteria | Gammaproteobacteria | Burkholderiales | Oxalobacteraceae | Massilia | NA | -6.825257 |
# Export the table to a CSV file
write.csv(final_table_betula_vs_populus_LMM_2219, file = "final_table_betula_vs_populus_LMM_2219.csv", row.names = FALSE)
# Export the table to a tab-separated TXT file
write.table(final_table_betula_vs_populus_LMM_2219, file = "final_table_betula_vs_populus_LMM_2219.txt", sep = "\t", row.names = FALSE)
#-------------------------------------------------------------------------------
# Bar Plot
#-------------------------------------------------------------------------------
# Filter significant results (you can adjust the threshold for significance as needed)
significant_results_spp_LMM_2219 <- subset(results_diff_abund_LMM_2219, padj < 0.05)
#significant_results_spp_LMM_2219 <- subset(results_diff_abund_LMM_2219)
# Create a data frame with ASV names and log2 fold change values
data_for_barplot_LMM_2219 <- data.frame(
ASV = rownames(significant_results_spp_LMM_2219),
Log2FoldChange = significant_results_spp_LMM_2219$log2FoldChange
)
data_for_barplot_2219 <- as.data.frame(final_asv_table_spp_LMM_2219)
data_for_barplot_2219$Genus <- ifelse(is.na(data_for_barplot_2219$Genus), "Unknown", data_for_barplot_2219$Genus)
# Add a new column for the absolute values of Log2FoldChange
data_for_barplot_LMM_2219$AbsLog2FoldChange <- abs(data_for_barplot_LMM_2219$Log2FoldChange)
# Sort the data frame by the absolute values of Log2FoldChange in descending order
data_for_barplot_LMM_2219 <- data_for_barplot_LMM_2219[order(-data_for_barplot_LMM_2219$AbsLog2FoldChange), ]
# Select the top 100 ASVs for the bar plot
data_for_barplot_LMM_2219 <- data_for_barplot_LMM_2219[1:50, ]
data_for_barplot_LMM_2219 <- na.omit(data_for_barplot_LMM_2219)
# Create the bar plot
deseq_plot2219_genus <- ggplot(data_for_barplot_2219, aes(x = ASV, y = Log2.Fold.Change, fill = Genus)) +
geom_bar(stat = "identity", color = "black") +
labs(x = "ASV", y = "Log2 Fold Change") +
theme_minimal() +
theme(
axis.title.x = element_text(size = 8),
axis.title.y = element_text(size = 8),
axis.text.x = element_text(angle = -90, hjust = 1, size = 6),
axis.text.y = element_text(size = 6),
legend.title = element_text(size = 12),
legend.text = element_text(size = 12),
panel.border = element_rect(color = "black", size = 1, fill = NA),
legend.position = "none",
axis.ticks = element_line(color = "black")
) +
scale_fill_manual(values = genus_colors)
deseq_plot2219_genus
ggsave("deseq_plot2219_genus.png", deseq_plot2219_genus, width=12, height=8)
#-------------------------------------------------------------------------------
# Bubble Plot
#-------------------------------------------------------------------------------
# Create the bubble plot
deseq_plot2219_genus2 <- ggplot(
data_for_barplot_2219,
aes(
x = fct_reorder(ASV, Log2.Fold.Change, .fun = ~median(., na.rm = TRUE), .desc = TRUE),
y = Log2.Fold.Change,
fill = Genus
)
) +
geom_hline(yintercept = 0, linewidth = 0.4, color = "grey60") +
geom_point(aes(size = -log10(Adjusted.P.value)), shape = 21, stroke = 0.6, color = "black") + # bubble/circle points
# scale_x_discrete(expand = expansion(mult = c(0.04, 0.02))) +
scale_size_area(
name = expression(-log[10]("adj p")),
max_size = 5,
limits = c(0, NA),
guide = "none"
) +
labs(x = "ASV", y = "Log2 Fold Change") +
theme_minimal() +
theme(
axis.title.x = element_text(size = 6),
axis.title.y = element_text(size = 6),
axis.text.x = element_text(angle = -90, vjust = 0.5, size = 6),
axis.text.y = element_text(size = 6),
legend.title = element_text(size = 6),
legend.text = element_text(size = 5),
legend.box.margin = margin(0, 0, 0, -12, unit = "pt"),
panel.border = element_rect(color = "black", size = 1, fill = NA),
axis.ticks = element_line(color = "black"),
legend.position = "none"
) +
guides(fill = guide_legend(override.aes = list(size = 2), keyheight = 0.5, keywidth = 0.5, ncol = 2)) +
scale_fill_manual(values = genus_colors)
deseq_plot2219_genus2
# Create the bar plot
deseq_plot2219_phylum <- ggplot(data_for_barplot_2219, aes(
x = fct_reorder(ASV, Log2.Fold.Change, .fun = ~median(., na.rm = TRUE), .desc = TRUE),
y = Log2.Fold.Change,
fill = Phylum
)
) +
geom_bar(stat = "identity", color = "black") +
labs(x = "ASV", y = "Log2 Fold Change") +
theme_minimal() +
theme(
axis.title.x = element_text(size = 8),
axis.title.y = element_text(size = 8),
axis.text.x = element_text(angle = -90, hjust = 1, size = 6),
axis.text.y = element_text(size = 6),
legend.title = element_text(size = 12),
legend.text = element_text(size = 12),
panel.border = element_rect(color = "black", size = 1, fill = NA),
legend.position = "none",
axis.ticks = element_line(color = "black")
) +
scale_fill_manual(values = phylum_colors)
deseq_plot2219_phylum
#ggsave("deseq_plot2219_phylum.png", deseq_plot2219_phylum, width=12, height=8)
#-------------------------------------------------------------------------------
# Bubble Plot
#-------------------------------------------------------------------------------
# Create the bubble plot
deseq_plot2219_phylum2 <- ggplot(
data_for_barplot_2219,
aes(x = ASV, y = Log2.Fold.Change, fill = Phylum)
) +
geom_hline(yintercept = 0, linewidth = 0.4, color = "grey60") +
geom_point(aes(size = -log10(Adjusted.P.value)), shape = 21, stroke = 0.6, color = "black") + # bubble/circle points
scale_size_continuous(
name = expression(-log[10]("adj p")),
# range = c(2, 4), # make min larger & max bigger; preserves proportions
guide = "none"
) +
labs(x = "ASV", y = "Log2 Fold Change") +
theme_minimal() +
theme(
axis.title.x = element_text(size = 6),
axis.title.y = element_text(size = 6),
axis.text.x = element_text(angle = -90, vjust = 0.5, size = 6),
axis.text.y = element_text(size = 6),
legend.title = element_text(size = 6),
legend.text = element_text(size = 5),
legend.box.margin = margin(0, 0, 0, -12, unit = "pt"),
panel.border = element_rect(color = "black", size = 1, fill = NA),
axis.ticks = element_line(color = "black")
) +
guides(fill = guide_legend(keyheight = 0.5, keywidth = 0.5)) +
scale_fill_manual(values = phylum_colors)
deseq_plot2219_phylum2
# ========= ONE UNIFIED, DEDUPED GENUS LEGEND =========
library(ggplot2)
library(rlang)
# Your existing ggplot objects:
plots <- list(
deseq_plot605_genus2,
deseq_plot1087_genus2,
deseq_plot1606_genus2,
deseq_plot1992_genus2,
deseq_plot2140_genus2,
deseq_plot2219_genus2
)
# 1) Read genera used by each plot's fill mapping, then make a unique union
get_plot_genera <- function(p) {
fill_var <- as.character(get_expr(p$mapping$fill))
vals <- as.character(p$data[[fill_var]])
vals[!is.na(vals)]
}
master_genus <- sort(unique(unlist(lapply(plots, get_plot_genera), use.names = FALSE)))
if (!length(master_genus)) stop("No genera found across plots.")
# 2) Build a named color vector for exactly that union
# (genus_colors must be a *named* vector: names(genus_colors) == genus strings)
genus_colors_full <- setNames(genus_colors[master_genus], master_genus)
missing <- setdiff(master_genus, names(genus_colors))
if (length(missing)) genus_colors_full[missing] <- "#BFBFBF" # fallback grey
# 3) Make a legend-only plot that DEFINITELY renders the unified legend
legend_df <- data.frame(Genus = factor(master_genus, levels = master_genus), x = 0, y = 0)
ncol_legend <- 3 # change to 3/4 if you want fewer rows
legend_plot <- ggplot(legend_df, aes(x, y, fill = Genus)) +
geom_point(shape = 21, color = "black", stroke = 0.6, size = 3, show.legend = TRUE) +
scale_fill_manual(values = genus_colors_full,
limits = master_genus,
drop = FALSE,
guide = "legend",
labels = function(x) {
x <- str_replace(x, "Methylobacterium-Methylorubrum", "Methylobacterium-\nMethylorubrum")
x <- str_replace(x, "Candidatus Ovatusbacter", "Candidatus\nOvatusbacter")
x
}
) + # force a legend
guides(fill = guide_legend(ncol = ncol_legend, keyheight = 0.6, keywidth = 0.6)) +
labs(fill = "Genus") +
theme_void(base_size = 7) +
theme(
legend.position = "bottom",
legend.title = element_text(size = 6),
legend.text = element_text(size = 6),
plot.margin = margin(0,0,0,0)
)
# 4) Save the legend as its own image.
# We don't extract the grob; we just save a small canvas that shows only the legend line(s).
rows <- ceiling(length(master_genus) / ncol_legend)
height_in <- max(0.35 * rows + 0.2, 0.6) # heuristic: ~0.35" per row + small padding
ggsave("unified_legend.pdf", legend_plot, width = 7, height = height_in, units = "in")
ggsave("unified_legend.png", legend_plot, width = 7, height = height_in, units = "in", dpi = 600)
# =====================================================
library(gridExtra)
library(jpeg)
# Arrange the plots in a grid:
# deseq_plots_combined <- arrangeGrob(deseq_plot437, deseq_plot605,
# deseq_plot1087, deseq_plot1606, deseq_plot1992, deseq_plot2140,
# deseq_plot2219, ncol=3, nrow=3)
deseq_plots_overall_genus_and_phyla_combined <- arrangeGrob(diff_abund_barplot_phylum,
diff_abund_barplot_genus, ncol = 1, nrow = 2)
deseq_plots_genus_combined <- arrangeGrob(deseq_plot437_genus, deseq_plot605_genus,
deseq_plot1087_genus, deseq_plot1606_genus, deseq_plot1992_genus, deseq_plot2140_genus,
deseq_plot2219_genus, ncol = 2, nrow = 4)
deseq_plots_genus_combined_bubble <- arrangeGrob(deseq_plot437_genus2, deseq_plot605_genus2,
deseq_plot1087_genus2, deseq_plot1606_genus2, deseq_plot1992_genus2, deseq_plot2140_genus2,
deseq_plot2219_genus2, legend_plot, ncol = 2, nrow = 4)
deseq_plots_genus_combined_bubble <- arrangeGrob(grobs = list(arrangeGrob(deseq_plot437_genus2,
top = textGrob("A", x = unit(0, "npc"), y = unit(1, "npc"), just = c("left",
"top"), gp = gpar(fontsize = 30, fontface = "bold"))), arrangeGrob(deseq_plot605_genus2,
top = textGrob("B", x = unit(0, "npc"), y = unit(1, "npc"), just = c("left",
"top"), gp = gpar(fontsize = 30, fontface = "bold"))), arrangeGrob(deseq_plot1087_genus2,
top = textGrob("C", x = unit(0, "npc"), y = unit(1, "npc"), just = c("left",
"top"), gp = gpar(fontsize = 30, fontface = "bold"))), arrangeGrob(deseq_plot1606_genus2,
top = textGrob("D", x = unit(0, "npc"), y = unit(1, "npc"), just = c("left",
"top"), gp = gpar(fontsize = 30, fontface = "bold"))), arrangeGrob(deseq_plot1992_genus2,
top = textGrob("E", x = unit(0, "npc"), y = unit(1, "npc"), just = c("left",
"top"), gp = gpar(fontsize = 30, fontface = "bold"))), arrangeGrob(deseq_plot2140_genus2,
top = textGrob("F", x = unit(0, "npc"), y = unit(1, "npc"), just = c("left",
"top"), gp = gpar(fontsize = 30, fontface = "bold"))), arrangeGrob(deseq_plot2219_genus2,
top = textGrob("G", x = unit(0, "npc"), y = unit(1, "npc"), just = c("left",
"top"), gp = gpar(fontsize = 30, fontface = "bold"))), arrangeGrob(legend_plot)),
ncol = 2, nrow = 4)
# deseq_plots_phylum_combined <- arrangeGrob(deseq_plot437_phylum,
# deseq_plot605_phylum, deseq_plot1087_phylum, deseq_plot1606_phylum,
# deseq_plot1992_phylum, deseq_plot2140_phylum, deseq_plot2219_phylum, ncol=2,
# nrow=4)
# Save the combined plot
# ggsave('deseq_plots_combined.png', deseq_plots_combined, width=21, height=14)
# # Adjust width and height as needed
ggsave("deseq_plots_genus_phylum_combined.png", deseq_plots_overall_genus_and_phyla_combined,
width = 3.25, height = 9.7, dpi = 600)
###########################
ggsave("deseq_plots_genus_combined_bubble.tiff", deseq_plots_genus_combined_bubble,
width = 7, height = 9.7, units = "in", dpi = 600, compression = "lzw", device = "tiff")
ggsave("deseq_plots_genus_combined_bubble.png", deseq_plots_genus_combined_bubble,
width = 7, height = 9.7, units = "in", dpi = 600)
ggsave("deseq_plots_genus_combined_bubble.pdf", deseq_plots_genus_combined_bubble,
width = 7, height = 9.7, units = "in", dpi = 600)
# ggsave('deseq_plots_phylum_combined.png', deseq_plots_phylum_combined,
# width=7, height=7.25, dpi=600)
library(patchwork)
library(gridExtra)
library(grid)
# Convert each full vertical stack into a grob
betula_comp_grob <- patchwork::patchworkGrob(betula_title_bar/betula_composition_gdd_gen3 +
plot_layout(heights = c(0.12, 1)) & theme(plot.margin = margin(0, 0, 0.1, 0,
unit = "pt")))
populus_comp_grob <- patchwork::patchworkGrob(populus_title_bar/populus_composition_gdd_gen3 +
plot_layout(heights = c(0.12, 1)) & theme(plot.margin = margin(0, 0, 0.1, 0,
unit = "pt")))
betula_deseq_grob <- patchwork::patchworkGrob(des_bet_title_bar/diff_abund_barplot_bet_cont_trend_genus +
plot_layout(heights = c(0.13, 1)) & theme(plot.margin = margin(0, 0, 0.1, 0,
unit = "pt")))
populus_deseq_grob <- patchwork::patchworkGrob(des_pop_title_bar/diff_abund_barplot_pop_cont_trend_genus +
plot_layout(heights = c(0.13, 1)) & theme(plot.margin = margin(0, 0, 0.1, 0,
unit = "pt")))
# Combine all panels into one grob
fig_taxa_deseq_combined <- arrangeGrob(grobs = list(betula_comp_grob, betula_deseq_grob,
populus_comp_grob, populus_deseq_grob), ncol = 2, nrow = 2, padding = unit(0,
"line"), widths = unit.c(unit(3.6, "in"), unit(3.9, "in")))
# Save
ggsave("fig_taxa_deseq_combined.tiff", plot = gridExtra::grid.arrange(fig_taxa_deseq_combined),
width = 7.5, height = 7, units = "in", dpi = 600, compression = "lzw", device = "tiff")
ggsave("fig_taxa_deseq_combined.png", plot = gridExtra::grid.arrange(fig_taxa_deseq_combined),
width = 7.5, height = 7, units = "in", dpi = 600)
library(patchwork)
library(gridExtra)
library(grid)
# Convert each full vertical stack into a grob
betula_comp_grob2 <- patchwork::patchworkGrob(betula_title_bar/betula_composition_gdd_gen3 +
plot_layout(heights = c(0.12, 1)) & theme(plot.margin = margin(0, 0, 0.1, 0,
unit = "pt")))
populus_comp_grob2 <- patchwork::patchworkGrob(populus_title_bar/populus_composition_gdd_gen3 +
plot_layout(heights = c(0.12, 1)) & theme(plot.margin = margin(0, 0, 0.1, 0,
unit = "pt")))
betula_deseq_grob2 <- patchwork::patchworkGrob(des_bet_title_bar/diff_abund_bubble_bet_cont_trend_genus +
plot_layout(heights = c(0.13, 1)) & theme(plot.margin = margin(0, 0, 0.1, 0,
unit = "pt")))
populus_deseq_grob2 <- patchwork::patchworkGrob(des_pop_title_bar/diff_abund_bubble_pop_cont_trend_genus +
plot_layout(heights = c(0.13, 1)) & theme(plot.margin = margin(0, 0, 0.1, 0,
unit = "pt")))
# Combine all panels into one grob
fig_taxa_deseq_combined2 <- arrangeGrob(grobs = list(betula_comp_grob2, betula_deseq_grob2,
populus_comp_grob2, populus_deseq_grob2), ncol = 2, nrow = 2, padding = unit(0,
"line"), widths = unit.c(unit(3, "in"), unit(4, "in")))
# Save
ggsave("fig_taxa_deseq_combined_bubble.tiff", plot = gridExtra::grid.arrange(fig_taxa_deseq_combined2),
width = 7, height = 7.5, units = "in", dpi = 600, compression = "lzw", device = "tiff")
ggsave("fig_taxa_deseq_combined_bubble.png", plot = gridExtra::grid.arrange(fig_taxa_deseq_combined2),
width = 7, height = 7.5, units = "in", dpi = 600)
ggsave("fig_taxa_deseq_combined_bubble.pdf", plot = gridExtra::grid.arrange(fig_taxa_deseq_combined2),
width = 7, height = 7.5, units = "in")
fig_taxa_deseq_combined3 <- gridExtra::arrangeGrob(
grobs = list(
betula_comp_grob2, betula_deseq_grob2,
populus_comp_grob2, populus_deseq_grob2
),
ncol = 2, nrow = 2,
padding = grid::unit(0, "line"),
widths = grid::unit.c(grid::unit(1, "null"), grid::unit(1.25, "null")) # <- right col ~1.8x wider
)
ggsave(
"fig_taxa_deseq_combined_bubble2.tiff",
plot = fig_taxa_deseq_combined3,
width = 7, height = 7.5, units = "in", # 2-col width
dpi = 300, compression = "lzw", device = "tiff"
)
library(phangorn)
##
## Attaching package: 'phangorn'
## The following object is masked from 'package:MuMIn':
##
## AICc
## The following objects are masked from 'package:vegan':
##
## diversity, treedist
library(Biostrings)
library(DECIPHER)
seqsdada <- colnames(seqtab.nochim)[as.numeric(substr(colnames(asv[, grepl("ASV",
colnames(asv))]), 4, nchar(colnames(asv[, grepl("ASV", colnames(asv))]))))]
names(seqsdada) <- seqsdada
# alignment <- AlignSeqs(DNAStringSet(seqsdada), anchor=NA,processors=6)
# phang.align <- phyDat(as(alignment, 'matrix'), type='DNA') dm <-
# dist.ml(phang.align) treeNJ <- NJ(dm) fit = pml(treeNJ, data=phang.align)
# fitGTR <- update(fit, k=4, inv=0.2) startTime<-Sys.time() fitGTR <-
# optim.pml(fitGTR, model='GTR', optInv=TRUE, optGamma=TRUE, rearrangement =
# 'stochastic', control = pml.control(trace = 0)) endTime<-Sys.time()
# endTime-startTime save(fitGTR,file='phangornTree.rdata')
asvMat <- as.matrix(asv[, grepl("ASV", colnames(asv))])
colnames(asvMat) <- seqsdada
ASV = otu_table(asvMat, taxa_are_rows = F)
taxa <- as.data.frame(taxa_rdp)
taxa <- taxa[rownames(taxa) %in% colnames(asv[, grepl("ASV", colnames(asv))]), ]
taxMat <- as.matrix(taxa)
rownames(taxMat) <- seqsdada
TAX = tax_table(taxMat)
META = sample_data(asv_scaled_noPlants_Phenology_filtered)
# TREE<-phy_tree(fitGTR$tree) physeq.unrooted = phyloseq(ASV, TAX, TREE)
# save(physeq.unrooted,file='physeqUnrooted') rooted.tree <- ape::root(TREE,
# outgroup=pick_new_outgroup(TREE), resolve.root=TRUE)
ps_phen2 = phyloseq(ASV, TAX, META)
# Create new objects & convert `Species` to factor & `Growing-Degree-Days-5C`
# to numeric for ALL objects used in stats
asv_scaled_noPlants_Phen_filt_LMM <- as.data.frame(asv_scaled_noPlants_Phenology_filtered)
# Convert the factor to numeric without changing the values
asv_scaled_noPlants_Phen_filt_LMM$`Growing-Degree-Days-5C` <- as.numeric(as.character(asv_scaled_noPlants_Phen_filt_LMM$`Growing-Degree-Days-5C`))
# Convert to `Species` to factor
asv_scaled_noPlants_Phen_filt_LMM$Species <- as.factor(asv_scaled_noPlants_Phen_filt_LMM$Species)
# Convert to `Plant_ID` to factor
asv_scaled_noPlants_Phen_filt_LMM$Plant_ID <- as.factor(asv_scaled_noPlants_Phen_filt_LMM$Plant_ID)
# Convert to `Collection-Month` to factor
asv_scaled_noPlants_Phen_filt_LMM$`Collection-Month` <- as.factor(asv_scaled_noPlants_Phen_filt_LMM$`Collection-Month`)
# Rename the 'Growing-Degree-Days-5C' variable to 'GDD5C'
colnames(asv_scaled_noPlants_Phen_filt_LMM)[colnames(asv_scaled_noPlants_Phen_filt_LMM) ==
"Growing-Degree-Days-5C"] <- "GDD_5C"
#-------------------------------------------------------------------------
# Homogeneity of Slopes faceted by 'Species'
#-------------------------------------------------------------------------
## NOTE: Homoegenity of slopes is just looking at the data but not the actual
## results, plus there are no error bars, so it's telling if there's
## potentially an interaction, but not definitely whether or not. Do NOT rely
## on this, especially b/c no error bars. Traditional ANCOVA moving away from
## this?
#-------------------------------------------------------------------------
# (a) x=`GDD_5C`
#-------------------------------------------------------------------------
# Untransformed: based on these plots is that the slopes are not homogenous
# between Betula and Populus, indicating that the relationship between
# Growing-Degree-Days-5C and specnumber varies significantly between the two
# species. If the slopes of the data within `Species` are unequal (they are),
# there is a potentially an interaction between `Species` and `GDD_5C`. If
# there are differences in the intercepts (there are), there may be differences
# in the medians across the levels (`Species`). This type of test is very
# preliminary, and only looks at the data, not the statistical results.
# NOTE: Transformations do not really help at all.
levels = c("Betula_populifolia", "Populus_tremuloides")
myplot_specnumber <- ggplot(data = asv_scaled_noPlants_Phen_filt_LMM, aes(x = GDD_5C,
y = specnumber)) + facet_grid(. ~ Species) + geom_point() + theme(panel.border = element_rect(color = "black",
fill = NA, size = 1))
myplot_specnumber <- myplot_specnumber + stat_smooth(method = lm, se = FALSE) + stat_smooth(se = FALSE,
color = "red") + labs(y = expression(~specnumber), x = expression(~GDD_5C))
myplot_specnumber
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
# Save the plot
ggsave("myplot_specnumber.jpg", plot = myplot_specnumber, width = 8, height = 6,
units = "in", dpi = 300)
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
library(ggplot2)
myplot_specnumber2 <- ggplot(data = asv_scaled_noPlants_Phen_filt_LMM, aes(x = GDD_5C,
y = log(specnumber))) + facet_grid(. ~ Species) + geom_point() + stat_smooth(method = lm,
se = FALSE) + stat_smooth(se = FALSE, color = "red") + labs(y = expression(~log(specnumber)),
x = expression(~GDD_5C)) + geom_text(aes(x = Inf, y = -Inf, label = paste("R-squared: ",
round(summary(lm(log(specnumber) ~ GDD_5C, data = asv_scaled_noPlants_Phen_filt_LMM))$r.squared,
3))), hjust = 1, vjust = 0, color = "blue", size = 3)
myplot_specnumber2
## Warning in geom_text(aes(x = Inf, y = -Inf, label = paste("R-squared: ", : All aesthetics have length 1, but the data has 71 rows.
## ℹ Please consider using `annotate()` or provide this layer with data containing
## a single row.
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
# Save the plot
ggsave("myplot_specnumber2.jpg", plot = myplot_specnumber2, width = 8, height = 6,
units = "in", dpi = 300)
## Warning in geom_text(aes(x = Inf, y = -Inf, label = paste("R-squared: ", : All aesthetics have length 1, but the data has 71 rows.
## ℹ Please consider using `annotate()` or provide this layer with data containing
## a single row.
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
#-------------------------------------------------------------------------
# Visualize data with a Scatterplot Matrix
#-------------------------------------------------------------------------
# To evaluate not only linearity, but also collinearity
plot <- scatterplotMatrix(~specnumber + Species + GDD_5C, regLine = TRUE, smooth = TRUE,
diagonal = TRUE, data = asv_scaled_noPlants_Phen_filt_LMM)
#-------------------------------------------------------------------------------
## Linear Mixed-Model (ASV Richness)
#-------------------------------------------------------------------------------
# install.packages('lmerTest') install.packages('lme4') install.packages('see')
library(lmerTest)
##
## Attaching package: 'lmerTest'
## The following object is masked from 'package:lme4':
##
## lmer
## The following object is masked from 'package:stats':
##
## step
library(lme4)
library(see)
# Fit the linear mixed-effects model
lmm_model_specnumber1 <- lmer(specnumber ~ Species + GDD_5C + Species:GDD_5C + (1 |
Plant_ID), data = asv_scaled_noPlants_Phen_filt_LMM)
# Obtain summary of the LMM with p-values
summary(lmm_model_specnumber1)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: specnumber ~ Species + GDD_5C + Species:GDD_5C + (1 | Plant_ID)
## Data: asv_scaled_noPlants_Phen_filt_LMM
##
## REML criterion at convergence: 675.2
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.4553 -0.6231 -0.3150 0.5254 2.7672
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 73.35 8.565
## Residual 715.27 26.745
## Number of obs: 71, groups: Plant_ID, 10
##
## Fixed effects:
## Estimate Std. Error df t value
## (Intercept) 19.688808 11.238082 54.357500 1.752
## SpeciesPopulus_tremuloides 29.923412 15.818440 53.939003 1.892
## GDD_5C 0.019788 0.006627 59.007084 2.986
## SpeciesPopulus_tremuloides:GDD_5C -0.019054 0.009356 59.032631 -2.037
## Pr(>|t|)
## (Intercept) 0.08542 .
## SpeciesPopulus_tremuloides 0.06391 .
## GDD_5C 0.00411 **
## SpeciesPopulus_tremuloides:GDD_5C 0.04618 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) SpcsP_ GDD_5C
## SpcsPpls_tr -0.710
## GDD_5C -0.850 0.604
## SpP_:GDD_5C 0.602 -0.849 -0.708
#-------------------------------------------------------------------------------
## LMM with sqrt-transformed `specnumber` (ASV richness)
#-------------------------------------------------------------------------------
# Fit the linear mixed-effects model
lmm_model_specnumber2 <- lmer(sqrt(specnumber) ~ Species + GDD_5C + Species:GDD_5C +
(1 | Plant_ID), data = asv_scaled_noPlants_Phen_filt_LMM)
# Obtain summary of the LMM with p-values
summary(lmm_model_specnumber2)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: sqrt(specnumber) ~ Species + GDD_5C + Species:GDD_5C + (1 | Plant_ID)
## Data: asv_scaled_noPlants_Phen_filt_LMM
##
## REML criterion at convergence: 311.8
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.5912 -0.6190 -0.2703 0.6369 2.3248
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0.4631 0.6805
## Residual 3.0840 1.7561
## Number of obs: 71, groups: Plant_ID, 10
##
## Fixed effects:
## Estimate Std. Error df t value
## (Intercept) 4.4841550 0.7575603 49.3960765 5.919
## SpeciesPopulus_tremuloides 2.4678375 1.0666277 48.9634297 2.314
## GDD_5C 0.0014666 0.0004352 58.9957851 3.370
## SpeciesPopulus_tremuloides:GDD_5C -0.0014963 0.0006144 59.0168159 -2.435
## Pr(>|t|)
## (Intercept) 3.04e-07 ***
## SpeciesPopulus_tremuloides 0.02493 *
## GDD_5C 0.00133 **
## SpeciesPopulus_tremuloides:GDD_5C 0.01791 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) SpcsP_ GDD_5C
## SpcsPpls_tr -0.710
## GDD_5C -0.828 0.588
## SpP_:GDD_5C 0.586 -0.827 -0.708
#-------------------------------------------------------------------------------
## LMM with log-transformed `specnumber` (ASV richness)
#-------------------------------------------------------------------------------
# Fit the linear mixed-effects model
lmm_model_specnumber3 <- lmer(log(specnumber) ~ Species + GDD_5C + Species:GDD_5C +
(1 | Plant_ID), data = asv_scaled_noPlants_Phen_filt_LMM)
# Obtain summary of the LMM with p-values
summary(lmm_model_specnumber3)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: log(specnumber) ~ Species + GDD_5C + Species:GDD_5C + (1 | Plant_ID)
## Data: asv_scaled_noPlants_Phen_filt_LMM
##
## REML criterion at convergence: 145.2
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.0358 -0.5705 -0.1964 0.7281 1.8708
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0.05344 0.2312
## Residual 0.25081 0.5008
## Number of obs: 71, groups: Plant_ID, 10
##
## Fixed effects:
## Estimate Std. Error df t value
## (Intercept) 2.9966979 0.2232205 43.6386072 13.425
## SpeciesPopulus_tremuloides 0.8607230 0.3143893 43.2191851 2.738
## GDD_5C 0.0004674 0.0001241 58.9876357 3.766
## SpeciesPopulus_tremuloides:GDD_5C -0.0005053 0.0001752 59.0046777 -2.884
## Pr(>|t|)
## (Intercept) < 2e-16 ***
## SpeciesPopulus_tremuloides 0.008946 **
## GDD_5C 0.000384 ***
## SpeciesPopulus_tremuloides:GDD_5C 0.005475 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) SpcsP_ GDD_5C
## SpcsPpls_tr -0.710
## GDD_5C -0.801 0.569
## SpP_:GDD_5C 0.567 -0.800 -0.708
#-------------------------------------------------------------------------------
## LMM with log-transformed `specnumber` (ASV richness) AND `Collection-Month`
## as random var?
#-------------------------------------------------------------------------------
# Fit the linear mixed-effects model
lmm_model_specnumber3_plantid_month <- lmer(log(specnumber) ~ Species + GDD_5C +
Species:GDD_5C + (1 | Plant_ID) + (1 | `Collection-Month`), data = asv_scaled_noPlants_Phen_filt_LMM)
## boundary (singular) fit: see help('isSingular')
# Obtain summary of the LMM with p-values
summary(lmm_model_specnumber3_plantid_month)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## log(specnumber) ~ Species + GDD_5C + Species:GDD_5C + (1 | Plant_ID) +
## (1 | `Collection-Month`)
## Data: asv_scaled_noPlants_Phen_filt_LMM
##
## REML criterion at convergence: 145.2
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.0358 -0.5705 -0.1964 0.7281 1.8708
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0.05344 0.2312
## Collection-Month (Intercept) 0.00000 0.0000
## Residual 0.25081 0.5008
## Number of obs: 71, groups: Plant_ID, 10; Collection-Month, 5
##
## Fixed effects:
## Estimate Std. Error df t value
## (Intercept) 2.9966979 0.2232205 43.6386071 13.425
## SpeciesPopulus_tremuloides 0.8607230 0.3143893 43.2191850 2.738
## GDD_5C 0.0004674 0.0001241 58.9876357 3.766
## SpeciesPopulus_tremuloides:GDD_5C -0.0005053 0.0001752 59.0046777 -2.884
## Pr(>|t|)
## (Intercept) < 2e-16 ***
## SpeciesPopulus_tremuloides 0.008946 **
## GDD_5C 0.000384 ***
## SpeciesPopulus_tremuloides:GDD_5C 0.005475 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) SpcsP_ GDD_5C
## SpcsPpls_tr -0.710
## GDD_5C -0.801 0.569
## SpP_:GDD_5C 0.567 -0.800 -0.708
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
#-------------------------------------------------------------------------------
## LMM with log-transformed `specnumber` (ASV richness) AND `Collection-Month`
## as random var?
#-------------------------------------------------------------------------------
# Fit the linear mixed-effects model
lmm_model_specnumber3_month <- lmer(log(specnumber) ~ Species + GDD_5C + Species:GDD_5C +
(1 | `Collection-Month`), data = asv_scaled_noPlants_Phen_filt_LMM)
## boundary (singular) fit: see help('isSingular')
# Obtain summary of the LMM with p-values
summary(lmm_model_specnumber3_month)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## log(specnumber) ~ Species + GDD_5C + Species:GDD_5C + (1 | `Collection-Month`)
## Data: asv_scaled_noPlants_Phen_filt_LMM
##
## REML criterion at convergence: 148.9
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.24143 -0.66545 -0.03587 0.67556 2.21427
##
## Random effects:
## Groups Name Variance Std.Dev.
## Collection-Month (Intercept) 0.000 0.0000
## Residual 0.296 0.5441
## Number of obs: 71, groups: Collection-Month, 5
##
## Fixed effects:
## Estimate Std. Error df t value
## (Intercept) 2.9966979 0.2149339 67.0000000 13.942
## SpeciesPopulus_tremuloides 0.8693607 0.3022729 67.0000000 2.876
## GDD_5C 0.0004674 0.0001348 67.0000000 3.467
## SpeciesPopulus_tremuloides:GDD_5C -0.0005084 0.0001903 67.0000000 -2.671
## Pr(>|t|)
## (Intercept) < 2e-16 ***
## SpeciesPopulus_tremuloides 0.005394 **
## GDD_5C 0.000924 ***
## SpeciesPopulus_tremuloides:GDD_5C 0.009477 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) SpcsP_ GDD_5C
## SpcsPpls_tr -0.711
## GDD_5C -0.904 0.643
## SpP_:GDD_5C 0.640 -0.904 -0.708
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
#-------------------------------------------------------------------------------
## LMM with square-transformed `specnumber` (ASV richness)
#-------------------------------------------------------------------------------
# Fit the linear mixed-effects model
lmm_model_specnumber4 <- lmer(I(specnumber^2) ~ Species + GDD_5C + Species:GDD_5C +
(1 | Plant_ID), data = asv_scaled_noPlants_Phen_filt_LMM)
# Obtain summary of the LMM with p-values
summary(lmm_model_specnumber4)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: I(specnumber^2) ~ Species + GDD_5C + Species:GDD_5C + (1 | Plant_ID)
## Data: asv_scaled_noPlants_Phen_filt_LMM
##
## REML criterion at convergence: 1334.8
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.2124 -0.6073 -0.3179 0.2176 3.5955
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 674875 821.5
## Residual 13902253 3728.6
## Number of obs: 71, groups: Plant_ID, 10
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 179.950 1518.066 60.205 0.119 0.9060
## SpeciesPopulus_tremuloides 2637.357 2135.943 59.849 1.235 0.2217
## GDD_5C 2.207 0.924 59.039 2.388 0.0202
## SpeciesPopulus_tremuloides:GDD_5C -1.948 1.304 59.072 -1.494 0.1405
##
## (Intercept)
## SpeciesPopulus_tremuloides
## GDD_5C *
## SpeciesPopulus_tremuloides:GDD_5C
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) SpcsP_ GDD_5C
## SpcsPpls_tr -0.711
## GDD_5C -0.877 0.623
## SpP_:GDD_5C 0.621 -0.877 -0.708
# Fit the linear mixed-effects model
lmm_model_specnumber6 <- lmer(log(specnumber) ~ Species + I(GDD_5C^3) + Species:I(GDD_5C^3) +
(1 | Plant_ID), data = asv_scaled_noPlants_Phen_filt_LMM)
## Warning: Some predictor variables are on very different scales: consider
## rescaling
## Warning: Some predictor variables are on very different scales: consider
## rescaling
# Obtain summary of the LMM with p-values
summary(lmm_model_specnumber6)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: log(specnumber) ~ Species + I(GDD_5C^3) + Species:I(GDD_5C^3) +
## (1 | Plant_ID)
## Data: asv_scaled_noPlants_Phen_filt_LMM
##
## REML criterion at convergence: 208.8
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.0494 -0.5860 -0.1789 0.7125 2.0497
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0.05285 0.2299
## Residual 0.25520 0.5052
## Number of obs: 71, groups: Plant_ID, 10
##
## Fixed effects:
## Estimate Std. Error df t value
## (Intercept) 3.317e+00 1.657e-01 1.835e+01 20.015
## SpeciesPopulus_tremuloides 4.983e-01 2.328e-01 1.789e+01 2.140
## I(GDD_5C^3) 7.197e-11 1.996e-11 5.899e+01 3.605
## SpeciesPopulus_tremuloides:I(GDD_5C^3) -7.444e-11 2.810e-11 5.903e+01 -2.649
## Pr(>|t|)
## (Intercept) 6.46e-14 ***
## SpeciesPopulus_tremuloides 0.046365 *
## I(GDD_5C^3) 0.000642 ***
## SpeciesPopulus_tremuloides:I(GDD_5C^3) 0.010342 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) SpcsP_ I(GDD_
## SpcsPpls_tr -0.712
## I(GDD_5C^3) -0.591 0.421
## SP_:I(GDD_5 0.420 -0.587 -0.710
## fit warnings:
## Some predictor variables are on very different scales: consider rescaling
# Fit the linear mixed-effects model
lmm_model_specnumber7 <- lmer(log(specnumber) ~ Species + I(GDD_5C^2) + Species:I(GDD_5C^2) +
(1 | Plant_ID), data = asv_scaled_noPlants_Phen_filt_LMM)
## Warning: Some predictor variables are on very different scales: consider
## rescaling
## Warning: Some predictor variables are on very different scales: consider
## rescaling
# Obtain summary of the LMM with p-values
summary(lmm_model_specnumber7)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: log(specnumber) ~ Species + I(GDD_5C^2) + Species:I(GDD_5C^2) +
## (1 | Plant_ID)
## Data: asv_scaled_noPlants_Phen_filt_LMM
##
## REML criterion at convergence: 177.1
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.0431 -0.5656 -0.1931 0.7212 2.0023
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0.05328 0.2308
## Residual 0.25184 0.5018
## Number of obs: 71, groups: Plant_ID, 10
##
## Fixed effects:
## Estimate Std. Error df t value
## (Intercept) 3.236e+00 1.773e-01 2.315e+01 18.253
## SpeciesPopulus_tremuloides 5.951e-01 2.492e-01 2.267e+01 2.388
## I(GDD_5C^2) 1.710e-07 4.584e-08 5.899e+01 3.731
## SpeciesPopulus_tremuloides:I(GDD_5C^2) -1.820e-07 6.460e-08 5.902e+01 -2.817
## Pr(>|t|)
## (Intercept) 3.04e-15 ***
## SpeciesPopulus_tremuloides 0.02567 *
## I(GDD_5C^2) 0.00043 ***
## SpeciesPopulus_tremuloides:I(GDD_5C^2) 0.00659 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) SpcsP_ I(GDD_
## SpcsPpls_tr -0.711
## I(GDD_5C^2) -0.657 0.467
## SP_:I(GDD_5 0.466 -0.654 -0.710
## fit warnings:
## Some predictor variables are on very different scales: consider rescaling
# Fit the linear mixed-effects model
lmm_model_specnumber8 <- lmer(specnumber ~ Species + I(GDD_5C^2) + Species:I(GDD_5C^2) +
(1 | Plant_ID), data = asv_scaled_noPlants_Phen_filt_LMM)
## Warning: Some predictor variables are on very different scales: consider
## rescaling
## Warning: Some predictor variables are on very different scales: consider
## rescaling
# Obtain summary of the LMM with p-values
summary(lmm_model_specnumber8)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: specnumber ~ Species + I(GDD_5C^2) + Species:I(GDD_5C^2) + (1 |
## Plant_ID)
## Data: asv_scaled_noPlants_Phen_filt_LMM
##
## REML criterion at convergence: 707.3
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.4743 -0.6055 -0.3295 0.5154 2.7859
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 72.64 8.523
## Residual 720.51 26.842
## Number of obs: 71, groups: Plant_ID, 10
##
## Fixed effects:
## Estimate Std. Error df t value
## (Intercept) 3.012e+01 8.598e+00 3.078e+01 3.502
## SpeciesPopulus_tremuloides 2.002e+01 1.207e+01 3.004e+01 1.659
## I(GDD_5C^2) 7.116e-06 2.452e-06 5.901e+01 2.903
## SpeciesPopulus_tremuloides:I(GDD_5C^2) -6.905e-06 3.455e-06 5.906e+01 -1.999
## Pr(>|t|)
## (Intercept) 0.00143 **
## SpeciesPopulus_tremuloides 0.10762
## I(GDD_5C^2) 0.00520 **
## SpeciesPopulus_tremuloides:I(GDD_5C^2) 0.05026 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) SpcsP_ I(GDD_
## SpcsPpls_tr -0.712
## I(GDD_5C^2) -0.725 0.516
## SP_:I(GDD_5 0.514 -0.722 -0.710
## fit warnings:
## Some predictor variables are on very different scales: consider rescaling
# Fit the linear mixed-effects model
lmm_model_specnumber9 <- lmer(specnumber ~ Species + I(GDD_5C^3) + Species:I(GDD_5C^3) +
(1 | Plant_ID), data = asv_scaled_noPlants_Phen_filt_LMM)
## Warning: Some predictor variables are on very different scales: consider
## rescaling
## Warning: Some predictor variables are on very different scales: consider
## rescaling
# Obtain summary of the LMM with p-values
summary(lmm_model_specnumber9)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: specnumber ~ Species + I(GDD_5C^3) + Species:I(GDD_5C^3) + (1 |
## Plant_ID)
## Data: asv_scaled_noPlants_Phen_filt_LMM
##
## REML criterion at convergence: 739
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.4614 -0.6082 -0.3383 0.4774 2.8198
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 71.52 8.457
## Residual 728.95 26.999
## Number of obs: 71, groups: Plant_ID, 10
##
## Fixed effects:
## Estimate Std. Error df t value
## (Intercept) 3.373e+01 7.909e+00 2.375e+01 4.265
## SpeciesPopulus_tremuloides 1.634e+01 1.109e+01 2.302e+01 1.473
## I(GDD_5C^3) 2.948e-09 1.067e-09 5.901e+01 2.763
## SpeciesPopulus_tremuloides:I(GDD_5C^3) -2.823e-09 1.502e-09 5.908e+01 -1.880
## Pr(>|t|)
## (Intercept) 0.000275 ***
## SpeciesPopulus_tremuloides 0.154334
## I(GDD_5C^3) 0.007628 **
## SpeciesPopulus_tremuloides:I(GDD_5C^3) 0.065065 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) SpcsP_ I(GDD_
## SpcsPpls_tr -0.713
## I(GDD_5C^3) -0.662 0.472
## SP_:I(GDD_5 0.470 -0.658 -0.710
## fit warnings:
## Some predictor variables are on very different scales: consider rescaling
# Fit the linear mixed-effects model
lmm_model_specnumber10 <- lmer(log(specnumber) ~ Species + GDD_5C + Species:GDD_5C +
(1 | Species/Plant_ID), data = asv_scaled_noPlants_Phen_filt_LMM)
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## unable to evaluate scaled gradient
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## Hessian is numerically singular: parameters are not uniquely determined
## Warning in as_lmerModLT(model, devfun): Model may not have converged with 1
## eigenvalue close to zero: -1.0e-09
# Obtain summary of the LMM with p-values
summary(lmm_model_specnumber10)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## log(specnumber) ~ Species + GDD_5C + Species:GDD_5C + (1 | Species/Plant_ID)
## Data: asv_scaled_noPlants_Phen_filt_LMM
##
## REML criterion at convergence: 145.2
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.0358 -0.5705 -0.1964 0.7281 1.8708
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID:Species (Intercept) 0.053435 0.23116
## Species (Intercept) 0.005335 0.07304
## Residual 0.250807 0.50081
## Number of obs: 71, groups: Plant_ID:Species, 10; Species, 2
##
## Fixed effects:
## Estimate Std. Error df t value
## (Intercept) 2.9966979 0.2348663 48.1689879 12.759
## SpeciesPopulus_tremuloides 0.8607231 0.3309234 47.8083143 2.601
## GDD_5C 0.0004674 0.0001241 58.9875769 3.766
## SpeciesPopulus_tremuloides:GDD_5C -0.0005053 0.0001752 59.0046190 -2.884
## Pr(>|t|)
## (Intercept) < 2e-16 ***
## SpeciesPopulus_tremuloides 0.012334 *
## GDD_5C 0.000384 ***
## SpeciesPopulus_tremuloides:GDD_5C 0.005475 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) SpcsP_ GDD_5C
## SpcsPpls_tr -0.710
## GDD_5C -0.761 0.540
## SpP_:GDD_5C 0.539 -0.760 -0.708
## optimizer (nloptwrap) convergence code: 0 (OK)
## unable to evaluate scaled gradient
## Hessian is numerically singular: parameters are not uniquely determined
# Fit the linear mixed-effects model
lmm_model_specnumber11 <- lmer(log(specnumber) ~ Species:GDD_5C + (1 | Species/Plant_ID),
data = asv_scaled_noPlants_Phen_filt_LMM)
# Obtain summary of the LMM with p-values
summary(lmm_model_specnumber11)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: log(specnumber) ~ Species:GDD_5C + (1 | Species/Plant_ID)
## Data: asv_scaled_noPlants_Phen_filt_LMM
##
## REML criterion at convergence: 147.7
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.0472 -0.5619 -0.2082 0.7356 1.8748
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID:Species (Intercept) 0.05358 0.2315
## Species (Intercept) 0.32097 0.5665
## Residual 0.25075 0.5008
## Number of obs: 71, groups: Plant_ID:Species, 10; Species, 2
##
## Fixed effects:
## Estimate Std. Error df t value
## (Intercept) 3.428e+00 4.304e-01 1.000e+00 7.964
## SpeciesBetula_populifolia:GDD_5C 4.416e-04 1.214e-04 5.713e+01 3.639
## SpeciesPopulus_tremuloides:GDD_5C -1.239e-05 1.210e-04 5.733e+01 -0.102
## Pr(>|t|)
## (Intercept) 0.079521 .
## SpeciesBetula_populifolia:GDD_5C 0.000591 ***
## SpeciesPopulus_tremuloides:GDD_5C 0.918826
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) SB_:GD
## SpB_:GDD_5C -0.212
## SpP_:GDD_5C -0.210 0.045
# Fit the linear mixed-effects model
lmm_model_specnumber_nested <- lmer(log(specnumber) ~ Species + GDD_5C + Species:GDD_5C +
(1 | GDD_5C/Plant_ID), data = asv_scaled_noPlants_Phen_filt_LMM)
## boundary (singular) fit: see help('isSingular')
# Obtain summary of the LMM with p-values
summary(lmm_model_specnumber_nested)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## log(specnumber) ~ Species + GDD_5C + Species:GDD_5C + (1 | GDD_5C/Plant_ID)
## Data: asv_scaled_noPlants_Phen_filt_LMM
##
## REML criterion at convergence: 148.9
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.24143 -0.66545 -0.03587 0.67556 2.21427
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID:GDD_5C (Intercept) 0.000 0.0000
## GDD_5C (Intercept) 0.000 0.0000
## Residual 0.296 0.5441
## Number of obs: 71, groups: Plant_ID:GDD_5C, 70; GDD_5C, 7
##
## Fixed effects:
## Estimate Std. Error df t value
## (Intercept) 2.9966979 0.2149339 67.0000000 13.942
## SpeciesPopulus_tremuloides 0.8693607 0.3022729 67.0000000 2.876
## GDD_5C 0.0004674 0.0001348 67.0000000 3.467
## SpeciesPopulus_tremuloides:GDD_5C -0.0005084 0.0001903 67.0000000 -2.671
## Pr(>|t|)
## (Intercept) < 2e-16 ***
## SpeciesPopulus_tremuloides 0.005394 **
## GDD_5C 0.000924 ***
## SpeciesPopulus_tremuloides:GDD_5C 0.009477 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) SpcsP_ GDD_5C
## SpcsPpls_tr -0.711
## GDD_5C -0.904 0.643
## SpP_:GDD_5C 0.640 -0.904 -0.708
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
lmm_model_specnumber_nested2 <- lmer(log(specnumber) ~ Species + GDD_5C + Species:GDD_5C +
Species:Plant_ID + (1 | Species/Plant_ID), data = asv_scaled_noPlants_Phen_filt_LMM)
## fixed-effect model matrix is rank deficient so dropping 10 columns / coefficients
## Warning in as_lmerModLT(model, devfun): Model may not have converged with 2
## eigenvalues close to zero: 1.1e-09 1.0e-11
# Obtain summary of the LMM with p-values
summary(lmm_model_specnumber_nested2)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## log(specnumber) ~ Species + GDD_5C + Species:GDD_5C + Species:Plant_ID +
## (1 | Species/Plant_ID)
## Data: asv_scaled_noPlants_Phen_filt_LMM
##
## REML criterion at convergence: 138.6
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.77335 -0.58297 -0.07487 0.68932 1.94596
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID:Species (Intercept) 0.228957 0.47849
## Species (Intercept) 0.004647 0.06817
## Residual 0.250778 0.50078
## Number of obs: 71, groups: Plant_ID:Species, 10; Species, 2
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) 2.9290205 0.5489996 59.0000000
## SpeciesPopulus_tremuloides 1.0157778 0.7762651 59.0000000
## GDD_5C 0.0004674 0.0001241 59.0000000
## SpeciesPopulus_tremuloides:GDD_5C -0.0005034 0.0001752 59.0000000
## SpeciesBetula_populifolia:Plant_ID8553606 0.5150627 0.7277125 59.0000000
## SpeciesBetula_populifolia:Plant_ID8553762 0.1419428 0.7277125 59.0000000
## SpeciesBetula_populifolia:Plant_ID8553879 -0.4906177 0.7277125 59.0000000
## SpeciesBetula_populifolia:Plant_ID8554325 0.1719989 0.7277125 59.0000000
## SpeciesPopulus_tremuloides:Plant_ID8987795 0.1471590 0.7246497 59.0000000
## SpeciesPopulus_tremuloides:Plant_ID8987955 -0.1474304 0.7277125 59.0000000
## SpeciesPopulus_tremuloides:Plant_ID8988752 -0.4202174 0.7277125 59.0000000
## SpeciesPopulus_tremuloides:Plant_ID8988899 -0.0424806 0.7277125 59.0000000
## t value Pr(>|t|)
## (Intercept) 5.335 1.59e-06 ***
## SpeciesPopulus_tremuloides 1.309 0.195763
## GDD_5C 3.767 0.000384 ***
## SpeciesPopulus_tremuloides:GDD_5C -2.873 0.005643 **
## SpeciesBetula_populifolia:Plant_ID8553606 0.708 0.481867
## SpeciesBetula_populifolia:Plant_ID8553762 0.195 0.846021
## SpeciesBetula_populifolia:Plant_ID8553879 -0.674 0.502823
## SpeciesBetula_populifolia:Plant_ID8554325 0.236 0.813975
## SpeciesPopulus_tremuloides:Plant_ID8987795 0.203 0.839774
## SpeciesPopulus_tremuloides:Plant_ID8987955 -0.203 0.840149
## SpeciesPopulus_tremuloides:Plant_ID8988752 -0.577 0.565833
## SpeciesPopulus_tremuloides:Plant_ID8988899 -0.058 0.953647
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) SpcsP_ GDD_5C SP_:GD SB_:P_ID85536 SB_:P_ID85537
## SpcsPpls_tr -0.707
## GDD_5C -0.326 0.230
## SpP_:GDD_5C 0.231 -0.325 -0.708
## SB_:P_ID85536 -0.663 0.469 0.000 0.000
## SB_:P_ID85537 -0.663 0.469 0.000 0.000 0.500
## SB_:P_ID85538 -0.663 0.469 0.000 0.000 0.500 0.500
## SB_:P_ID8554 -0.663 0.469 0.000 0.000 0.500 0.500
## SP_:P_ID89877 0.000 -0.472 0.000 0.005 0.000 0.000
## SP_:P_ID89879 0.000 -0.469 0.000 0.000 0.000 0.000
## SP_:P_ID89887 0.000 -0.469 0.000 0.000 0.000 0.000
## SP_:P_ID89888 0.000 -0.469 0.000 0.000 0.000 0.000
## SB_:P_ID85538 SB_:P_ID8554 SP_:P_ID89877 SP_:P_ID89879
## SpcsPpls_tr
## GDD_5C
## SpP_:GDD_5C
## SB_:P_ID85536
## SB_:P_ID85537
## SB_:P_ID85538
## SB_:P_ID8554 0.500
## SP_:P_ID89877 0.000 0.000
## SP_:P_ID89879 0.000 0.000 0.502
## SP_:P_ID89887 0.000 0.000 0.502 0.500
## SP_:P_ID89888 0.000 0.000 0.502 0.500
## SP_:P_ID89887
## SpcsPpls_tr
## GDD_5C
## SpP_:GDD_5C
## SB_:P_ID85536
## SB_:P_ID85537
## SB_:P_ID85538
## SB_:P_ID8554
## SP_:P_ID89877
## SP_:P_ID89879
## SP_:P_ID89887
## SP_:P_ID89888 0.500
## fit warnings:
## fixed-effect model matrix is rank deficient so dropping 10 columns / coefficients
#-------------------------------------------------------------------------------
## ANCOVA
#-------------------------------------------------------------------------------
# Perform ANCOVA
ancova_specnumber1 <- lm(specnumber ~ Species + GDD_5C + Species:GDD_5C, data = asv_scaled_noPlants_Phen_filt_LMM)
Anova(ancova_specnumber1, type = 3)
## Anova Table (Type III tests)
##
## Response: specnumber
## Sum Sq Df F value Pr(>F)
## (Intercept) 2484 1 3.1951 0.078381 .
## Species 2959 1 3.8065 0.055238 .
## GDD_5C 6376 1 8.2016 0.005583 **
## Species:GDD_5C 3001 1 3.8603 0.053592 .
## Residuals 52089 67
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(ancova_specnumber1)
##
## Call:
## lm(formula = specnumber ~ Species + GDD_5C + Species:GDD_5C,
## data = asv_scaled_noPlants_Phen_filt_LMM)
##
## Residuals:
## Min 1Q Median 3Q Max
## -38.156 -17.967 -6.591 12.375 75.894
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 19.688808 11.014779 1.787 0.07838 .
## SpeciesPopulus_tremuloides 30.222601 15.490662 1.951 0.05524 .
## GDD_5C 0.019788 0.006909 2.864 0.00558 **
## SpeciesPopulus_tremuloides:GDD_5C -0.019163 0.009753 -1.965 0.05359 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 27.88 on 67 degrees of freedom
## Multiple R-squared: 0.111, Adjusted R-squared: 0.07119
## F-statistic: 2.788 on 3 and 67 DF, p-value: 0.04726
# Adjusted R^2 = 0.07108
#------------------------------------------------------------------------------
# Perform ANCOVA (log-transformed)
ancova_specnumber2 <- lm(log(specnumber) ~ Species + GDD_5C + Species:GDD_5C, data = asv_scaled_noPlants_Phen_filt_LMM)
Anova(ancova_specnumber2, type = 3)
## Anova Table (Type III tests)
##
## Response: log(specnumber)
## Sum Sq Df F value Pr(>F)
## (Intercept) 57.544 1 194.3909 < 2.2e-16 ***
## Species 2.449 1 8.2718 0.005394 **
## GDD_5C 3.558 1 12.0194 0.000924 ***
## Species:GDD_5C 2.112 1 7.1355 0.009477 **
## Residuals 19.834 67
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(ancova_specnumber2)
##
## Call:
## lm(formula = log(specnumber) ~ Species + GDD_5C + Species:GDD_5C,
## data = asv_scaled_noPlants_Phen_filt_LMM)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.21952 -0.36206 -0.01952 0.36756 1.20474
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.9966979 0.2149339 13.942 < 2e-16 ***
## SpeciesPopulus_tremuloides 0.8693607 0.3022729 2.876 0.005394 **
## GDD_5C 0.0004674 0.0001348 3.467 0.000924 ***
## SpeciesPopulus_tremuloides:GDD_5C -0.0005084 0.0001903 -2.671 0.009477 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.5441 on 67 degrees of freedom
## Multiple R-squared: 0.165, Adjusted R-squared: 0.1276
## F-statistic: 4.414 on 3 and 67 DF, p-value: 0.006817
# Adjusted R^2 = 0.1285
#-------------------------------------------------------------------------
# Formal Test of Homoscedasticity:
#-------------------------------------------------------------------------
bptest(ancova_specnumber1) # p = 0.39; homoscedasticity is good
##
## studentized Breusch-Pagan test
##
## data: ancova_specnumber1
## BP = 3.1155, df = 3, p-value = 0.3742
bptest(ancova_specnumber2) # p = 0.39; homoscedasticity is good
##
## studentized Breusch-Pagan test
##
## data: ancova_specnumber2
## BP = 2.9787, df = 3, p-value = 0.3949
#-------------------------------------------------------------------------
# Formal Test of Linearity (RESET Test)
#-------------------------------------------------------------------------
resettest(ancova_specnumber1, type = "regressor", data = asv_scaled_noPlants_Phen_filt_LMM) # p = 0.74; Linearity is good
##
## RESET test
##
## data: ancova_specnumber1
## RESET = 0.28802, df1 = 2, df2 = 65, p-value = 0.7507
resettest(ancova_specnumber2, type = "regressor", data = asv_scaled_noPlants_Phen_filt_LMM) # p = 0.59; Linearity is good.
##
## RESET test
##
## data: ancova_specnumber2
## RESET = 0.51204, df1 = 2, df2 = 65, p-value = 0.6017
#--------------------------------------------------------------------------
# Formal Test of Serial Correlation
#--------------------------------------------------------------------------
dwtest(ancova_specnumber1) # DW = 0.9941 -> may have autocorrelation
##
## Durbin-Watson test
##
## data: ancova_specnumber1
## DW = 2.5775, p-value = 0.9938
## alternative hypothesis: true autocorrelation is greater than 0
dwtest(ancova_specnumber2) # DW = 0.9969 -> may have autocorrelation
##
## Durbin-Watson test
##
## data: ancova_specnumber2
## DW = 2.6284, p-value = 0.9968
## alternative hypothesis: true autocorrelation is greater than 0
# DW ranges from 0-4, with ~2 = no autocorrelation
#-------------------------------------------------------------------------
## Variance Inflation Factors (VIFs)
#-------------------------------------------------------------------------
vif(ancova_specnumber1)
## SpeciesPopulus_tremuloides GDD_5C
## 5.477531 2.007581
## SpeciesPopulus_tremuloides:GDD_5C
## 6.454243
vif(ancova_specnumber2)
## SpeciesPopulus_tremuloides GDD_5C
## 5.477531 2.007581
## SpeciesPopulus_tremuloides:GDD_5C
## 6.454243
## In summary, multicollinearity exists in the model, particularly for the
## interaction term and the SpeciesPopulus_tremuloides predictor
#-------------------------------------------------------------------------
## AIC:
#-------------------------------------------------------------------------
AIC(ancova_specnumber1) #AIC = 679.3519
## [1] 679.9487
AIC(ancova_specnumber2) #AIC = 121.0137
## [1] 120.9426
## `ancova_specnumber2` has lowest AIC -> likely the better ANCOVA model (plus
## better R^2)
## NOTE: This block of code & associated analyses ONLY apply to ANCOVA, not the
## LMM.
#-------------------------------------------------------------------------
## To be sure of my model, let's run formal diagnostics:
#-------------------------------------------------------------------------
# Formal Test of Normality (Shapiro-Wilks)
#-------------------------------------------------------------------------
shapiro.test(residuals(lmm_model_specnumber1)) # p=5.141e-05 -> NOT Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_specnumber1)
## W = 0.90418, p-value = 5.071e-05
shapiro.test(residuals(lmm_model_specnumber2)) # p=0.006245 -> NOT Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_specnumber2)
## W = 0.94932, p-value = 0.006188
shapiro.test(residuals(lmm_model_specnumber3)) # p=0.1763 -> Normality is good!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_specnumber3)
## W = 0.97514, p-value = 0.1707
shapiro.test(residuals(lmm_model_specnumber4)) # p=1.27e-08 -> NOT Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_specnumber4)
## W = 0.79234, p-value = 1.27e-08
shapiro.test(residuals(ancova_specnumber1)) # p=6.145e-05 -> NOT Normal
##
## Shapiro-Wilk normality test
##
## data: residuals(ancova_specnumber1)
## W = 0.90615, p-value = 6.103e-05
shapiro.test(residuals(ancova_specnumber2)) # p=0.7853 -> MOST Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(ancova_specnumber2)
## W = 0.98873, p-value = 0.7794
shapiro.test(residuals(lmm_model_specnumber3_plantid_month)) # p=0.1786 -> Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_specnumber3_plantid_month)
## W = 0.97514, p-value = 0.1707
shapiro.test(residuals(lmm_model_specnumber3_month)) # p=0.7729 -> Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_specnumber3_month)
## W = 0.98873, p-value = 0.7794
shapiro.test(residuals(lmm_model_specnumber6))
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_specnumber6)
## W = 0.97786, p-value = 0.2423
shapiro.test(residuals(lmm_model_specnumber7))
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_specnumber7)
## W = 0.97837, p-value = 0.2584
shapiro.test(residuals(lmm_model_specnumber8))
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_specnumber8)
## W = 0.89647, p-value = 2.499e-05
shapiro.test(residuals(lmm_model_specnumber9))
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_specnumber9)
## W = 0.8894, p-value = 1.337e-05
shapiro.test(residuals(lmm_model_specnumber10))
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_specnumber10)
## W = 0.97514, p-value = 0.1707
shapiro.test(residuals(lmm_model_specnumber11))
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_specnumber11)
## W = 0.9757, p-value = 0.1837
#-------------------------------------------------------------------------
## Check Diagnostic Statistics/Assumptions
#-------------------------------------------------------------------------
check_model(lmm_model_specnumber1, check = c("pp_check", "normality", "vif", "linearity",
"homogeneity", "outliers"))
check_model(lmm_model_specnumber2, check = c("pp_check", "normality", "vif", "linearity",
"homogeneity", "outliers"))
check_model(lmm_model_specnumber3, check = c("pp_check", "normality", "vif", "linearity",
"homogeneity", "outliers"))
check_model(lmm_model_specnumber4, check = c("pp_check", "normality", "vif", "linearity",
"homogeneity", "outliers"))
check_model(ancova_specnumber1)
check_model(ancova_specnumber2)
check_model(lmm_model_specnumber3_plantid_month, check = c("pp_check", "normality",
"vif", "linearity", "homogeneity", "outliers"))
check_model(lmm_model_specnumber3_month, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_specnumber6, check = c("pp_check", "normality", "vif", "linearity",
"homogeneity", "outliers"))
check_model(lmm_model_specnumber7, check = c("pp_check", "normality", "vif", "linearity",
"homogeneity", "outliers"))
check_model(lmm_model_specnumber8, check = c("pp_check", "normality", "vif", "linearity",
"homogeneity", "outliers"))
check_model(lmm_model_specnumber9, check = c("pp_check", "normality", "vif", "linearity",
"homogeneity", "outliers"))
check_model(lmm_model_specnumber10, check = c("pp_check", "normality", "vif", "linearity",
"homogeneity", "outliers"))
check_model(lmm_model_specnumber11, check = c("pp_check", "normality", "vif", "linearity",
"homogeneity", "outliers"))
## `lmm_model_specnumber2` and `lmm_model_specnumber3` look to have the best
## residuals diagnostics. BUT: `lmm_model_specnumber3` looks better + given
## everything else (AICs, BICs, normality, etc.)
#-------------------------------------------------------------------------
## Compare Model Fits with anova():
#-------------------------------------------------------------------------
# Compare 'model' with ANCOVA model:
anova(lmm_model_specnumber1, lmm_model_specnumber2, lmm_model_specnumber3, lmm_model_specnumber4,
ancova_specnumber1, ancova_specnumber2, lmm_model_specnumber3_plantid_month,
lmm_model_specnumber3_month, lmm_model_specnumber6, lmm_model_specnumber7, lmm_model_specnumber8,
lmm_model_specnumber9, lmm_model_specnumber10, lmm_model_specnumber11)
## refitting model(s) with ML (instead of REML)
## Data: asv_scaled_noPlants_Phen_filt_LMM
## Models:
## ancova_specnumber1: specnumber ~ Species + GDD_5C + Species:GDD_5C
## ancova_specnumber2: log(specnumber) ~ Species + GDD_5C + Species:GDD_5C
## lmm_model_specnumber1: specnumber ~ Species + GDD_5C + Species:GDD_5C + (1 | Plant_ID)
## lmm_model_specnumber2: sqrt(specnumber) ~ Species + GDD_5C + Species:GDD_5C + (1 | Plant_ID)
## lmm_model_specnumber3: log(specnumber) ~ Species + GDD_5C + Species:GDD_5C + (1 | Plant_ID)
## lmm_model_specnumber4: I(specnumber^2) ~ Species + GDD_5C + Species:GDD_5C + (1 | Plant_ID)
## lmm_model_specnumber3_month: log(specnumber) ~ Species + GDD_5C + Species:GDD_5C + (1 | `Collection-Month`)
## lmm_model_specnumber6: log(specnumber) ~ Species + I(GDD_5C^3) + Species:I(GDD_5C^3) + (1 | Plant_ID)
## lmm_model_specnumber7: log(specnumber) ~ Species + I(GDD_5C^2) + Species:I(GDD_5C^2) + (1 | Plant_ID)
## lmm_model_specnumber8: specnumber ~ Species + I(GDD_5C^2) + Species:I(GDD_5C^2) + (1 | Plant_ID)
## lmm_model_specnumber9: specnumber ~ Species + I(GDD_5C^3) + Species:I(GDD_5C^3) + (1 | Plant_ID)
## lmm_model_specnumber11: log(specnumber) ~ Species:GDD_5C + (1 | Species/Plant_ID)
## lmm_model_specnumber3_plantid_month: log(specnumber) ~ Species + GDD_5C + Species:GDD_5C + (1 | Plant_ID) + (1 | `Collection-Month`)
## lmm_model_specnumber10: log(specnumber) ~ Species + GDD_5C + Species:GDD_5C + (1 | Species/Plant_ID)
## npar AIC BIC logLik deviance
## ancova_specnumber1 5 679.95 691.26 -334.97 669.95
## ancova_specnumber2 5 120.94 132.26 -55.47 110.94
## lmm_model_specnumber1 6 681.35 694.93 -334.68 669.35
## lmm_model_specnumber2 6 296.44 310.02 -142.22 284.44
## lmm_model_specnumber3 6 120.24 133.81 -54.12 108.24
## lmm_model_specnumber4 6 1379.96 1393.54 -683.98 1367.96
## lmm_model_specnumber3_month 6 122.94 136.52 -55.47 110.94
## lmm_model_specnumber6 6 121.30 134.88 -54.65 109.30
## lmm_model_specnumber7 6 120.49 134.06 -54.24 108.49
## lmm_model_specnumber8 6 681.80 695.37 -334.90 669.80
## lmm_model_specnumber9 6 682.51 696.09 -335.26 670.51
## lmm_model_specnumber11 6 126.74 140.32 -57.37 114.74
## lmm_model_specnumber3_plantid_month 7 122.24 138.07 -54.12 108.24
## lmm_model_specnumber10 7 122.24 138.07 -54.12 108.24
## Chisq Df Pr(>Chisq)
## ancova_specnumber1
## ancova_specnumber2 559.0061 0
## lmm_model_specnumber1 0.0000 1 1.00000
## lmm_model_specnumber2 384.9114 0
## lmm_model_specnumber3 176.2046 0
## lmm_model_specnumber4 0.0000 0
## lmm_model_specnumber3_month 1257.0197 0
## lmm_model_specnumber6 1.6424 0
## lmm_model_specnumber7 0.8141 0
## lmm_model_specnumber8 0.0000 0
## lmm_model_specnumber9 0.0000 0
## lmm_model_specnumber11 555.7686 0
## lmm_model_specnumber3_plantid_month 6.5084 1 0.01074 *
## lmm_model_specnumber10 0.0000 0
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# `lmm_model_specnumber3` has the lowest AIC and BIC, so it's likely the best
# model. It also has lowest deviance and highest logLik (all followed closely
# `by ancova_specnumber2`)
# ANOVA of LMM model using `car` package.
library(car)
anova_lmm_specnumber1 <- Anova(lmm_model_specnumber1)
anova_lmm_specnumber2 <- Anova(lmm_model_specnumber2)
anova_lmm_specnumber3 <- Anova(lmm_model_specnumber3)
anova_lmm_specnumber4 <- Anova(lmm_model_specnumber4)
anova_ancova_specnumber1 <- Anova(ancova_specnumber1)
anova_ancova_specnumber2 <- Anova(ancova_specnumber2)
anova_lmm_model_specnumber3_plantid_month <- Anova(lmm_model_specnumber3_plantid_month)
anova_lmm_model_specnumber3_month <- Anova(lmm_model_specnumber3_month)
summary(anova_lmm_specnumber1)
## Chisq Df Pr(>Chisq)
## Min. :0.09392 Min. :1 Min. :0.02881
## 1st Qu.:2.12080 1st Qu.:1 1st Qu.:0.03525
## Median :4.14767 Median :1 Median :0.04169
## Mean :3.00691 Mean :1 Mean :0.27658
## 3rd Qu.:4.46341 3rd Qu.:1 3rd Qu.:0.40047
## Max. :4.77914 Max. :1 Max. :0.75925
summary(anova_lmm_specnumber2)
## Chisq Df Pr(>Chisq)
## Min. :0.2831 Min. :1 Min. :0.01487
## 1st Qu.:2.8568 1st Qu.:1 1st Qu.:0.01733
## Median :5.4305 Median :1 Median :0.01979
## Mean :3.8817 Mean :1 Mean :0.20977
## 3rd Qu.:5.6811 3rd Qu.:1 3rd Qu.:0.30723
## Max. :5.9316 Max. :1 Max. :0.59466
summary(anova_lmm_specnumber3)
## Chisq Df Pr(>Chisq)
## Min. :0.5135 Min. :1 Min. :0.003929
## 1st Qu.:3.2384 1st Qu.:1 1st Qu.:0.009267
## Median :5.9633 Median :1 Median :0.014606
## Mean :4.9311 Mean :1 Mean :0.164061
## 3rd Qu.:7.1399 3rd Qu.:1 3rd Qu.:0.244127
## Max. :8.3165 Max. :1 Max. :0.473649
summary(anova_lmm_specnumber4)
## Chisq Df Pr(>Chisq)
## Min. :0.02457 Min. :1 Min. :0.05955
## 1st Qu.:1.12816 1st Qu.:1 1st Qu.:0.09738
## Median :2.23176 Median :1 Median :0.13520
## Mean :1.93540 Mean :1 Mean :0.35673
## 3rd Qu.:2.89081 3rd Qu.:1 3rd Qu.:0.50532
## Max. :3.54986 Max. :1 Max. :0.87544
summary(anova_ancova_specnumber1)
## Sum Sq Df F value Pr(>F)
## Min. : 129.9 Min. : 1.0 Min. :0.1671 Min. :0.04083
## 1st Qu.: 2283.3 1st Qu.: 1.0 1st Qu.:2.0137 1st Qu.:0.04721
## Median : 3191.3 Median : 1.0 Median :3.8603 Median :0.05359
## Mean :14650.3 Mean :17.5 Mean :2.7923 Mean :0.25948
## 3rd Qu.:15558.3 3rd Qu.:17.5 3rd Qu.:4.1049 3rd Qu.:0.36881
## Max. :52088.5 Max. :67.0 Max. :4.3496 Max. :0.68402
## NA's :1 NA's :1
summary(anova_ancova_specnumber2)
## Sum Sq Df F value Pr(>F)
## Min. : 0.3445 Min. : 1.0 Min. :1.164 Min. :0.009477
## 1st Qu.: 1.1911 1st Qu.: 1.0 1st Qu.:3.070 1st Qu.:0.019259
## Median : 1.7928 Median : 1.0 Median :4.977 Median :0.029041
## Mean : 5.9409 Mean :17.5 Mean :4.425 Mean :0.107684
## 3rd Qu.: 6.5426 3rd Qu.:17.5 3rd Qu.:6.056 3rd Qu.:0.156787
## Max. :19.8336 Max. :67.0 Max. :7.136 Max. :0.284534
## NA's :1 NA's :1
summary(anova_lmm_model_specnumber3_plantid_month)
## Chisq Df Pr(>Chisq)
## Min. :0.5135 Min. :1 Min. :0.003929
## 1st Qu.:3.2384 1st Qu.:1 1st Qu.:0.009267
## Median :5.9633 Median :1 Median :0.014606
## Mean :4.9311 Mean :1 Mean :0.164061
## 3rd Qu.:7.1399 3rd Qu.:1 3rd Qu.:0.244127
## Max. :8.3165 Max. :1 Max. :0.473649
summary(anova_lmm_model_specnumber3_month)
## Chisq Df Pr(>Chisq)
## Min. :1.164 Min. :1 Min. :0.007557
## 1st Qu.:3.070 1st Qu.:1 1st Qu.:0.016623
## Median :4.977 Median :1 Median :0.025689
## Mean :4.425 Mean :1 Mean :0.104637
## 3rd Qu.:6.056 3rd Qu.:1 3rd Qu.:0.153177
## Max. :7.136 Max. :1 Max. :0.280665
#-------------------------------------------------------------------------------
## CHOICE: LMM with log-transformed `specnumber` (ASV richness) !!!
#-------------------------------------------------------------------------------
# `lmm_model_specnumber3`
#-------------------------------------------------------------------------------
## ANALYSIS/JUSTIFICATION:
## 1. Diagnostic statistics: `lmm_model_specnumber3` has slightly worse
## diagnostic statistics than `lmm_model_specnumber3_month`, particularly in
## terms of linearity, homogeneity of variance, and normality. 2. Collinearity:
## `lmm_model_specnumber3` has better collinearity than
## `lmm_model_specnumber3_month`, with no collinearity problems between
## predictors. Model fit: `lmm_model_specnumber3` has slightly lower AIC and
## BIC values than `lmm_model_specnumber3_month`, and lowest overall,
## indicating a slightly better fit compared to `lmm_model_specnumber3_month`.
## 3. Convergence: `lmm_model_specnumber3` does not have a convergence or
## singularity issue, unlike ``lmm_model_specnumber3`.
# While diagnostic statistics are important, the absence of collinearity issues
# and the ability to converge without singularity problems are also crucial
# considerations. Furthermore, the slightly better model fit of
# `lmm_model_specnumber3` suggests that it may provide a better balance between
# model complexity and goodness of fit.
# THIS IS WHY WE CHOOSE `lmm_model_specnumber3`
# Fit the linear mixed-effects model
lmm_model_specnumber3 <- lmer(log(specnumber) ~ Species + GDD_5C + Species:GDD_5C +
(1 | Plant_ID), data = asv_scaled_noPlants_Phen_filt_LMM)
# Obtain summary of the LMM with p-values
summary(lmm_model_specnumber3)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: log(specnumber) ~ Species + GDD_5C + Species:GDD_5C + (1 | Plant_ID)
## Data: asv_scaled_noPlants_Phen_filt_LMM
##
## REML criterion at convergence: 145.2
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.0358 -0.5705 -0.1964 0.7281 1.8708
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0.05344 0.2312
## Residual 0.25081 0.5008
## Number of obs: 71, groups: Plant_ID, 10
##
## Fixed effects:
## Estimate Std. Error df t value
## (Intercept) 2.9966979 0.2232205 43.6386072 13.425
## SpeciesPopulus_tremuloides 0.8607230 0.3143893 43.2191851 2.738
## GDD_5C 0.0004674 0.0001241 58.9876357 3.766
## SpeciesPopulus_tremuloides:GDD_5C -0.0005053 0.0001752 59.0046777 -2.884
## Pr(>|t|)
## (Intercept) < 2e-16 ***
## SpeciesPopulus_tremuloides 0.008946 **
## GDD_5C 0.000384 ***
## SpeciesPopulus_tremuloides:GDD_5C 0.005475 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) SpcsP_ GDD_5C
## SpcsPpls_tr -0.710
## GDD_5C -0.801 0.569
## SpP_:GDD_5C 0.567 -0.800 -0.708
# install.packages('MuMIn')
library(MuMIn)
# Calculate marginal R-squared for `lmm_model_specnumber3`
specnumber3_marginal_r_squared <- r.squaredGLMM(lmm_model_specnumber3, mu0 = "fixed")
print(specnumber3_marginal_r_squared)
## R2m R2c
## [1,] 0.1546421 0.3031162
#--------------------------------------------------------------
## Marginal R^2 for `Species` (using `lmm_model_specnumber3`)
#--------------------------------------------------------------
# install.packages('MuMIn')
library(MuMIn)
# Fit the linear mixed-effects model with just `Species`
lmm_model_specnumber_sp <- lmer(log(specnumber) ~ Species + (1 | Plant_ID), data = asv_scaled_noPlants_Phen_filt_LMM)
# Calculate marginal R-squared for `Species`
specnumber_marginal_r_squared_sp <- r.squaredGLMM(lmm_model_specnumber_sp, mu0 = "fixed")
print(specnumber_marginal_r_squared_sp)
## R2m R2c
## [1,] 0.01284875 0.1445946
#--------------------------------------------------------------
## Marginal R^2 for `GDD_5C` (using `lmm_model_specnumber3_month`)
#--------------------------------------------------------------
# Fit the linear mixed-effects model with just `Species`
lmm_model_specnumber_gdd <- lmer(log(specnumber) ~ GDD_5C + (1 | Plant_ID), data = asv_scaled_noPlants_Phen_filt_LMM)
# Calculate marginal R-squared for `Species`
specnumber_marginal_r_squared_gdd <- r.squaredGLMM(lmm_model_specnumber_gdd, mu0 = "fixed")
print(specnumber_marginal_r_squared_gdd)
## R2m R2c
## [1,] 0.06120819 0.1915023
#------------------------------------------------------------------------------------
## Marginal R^2 for `Species:GDD_5C` interaction only (using
## `lmm_model_specnumber3`)
#------------------------------------------------------------------------------------
# Fit the linear mixed-effects model with just `Species`
lmm_model_specnumber_interaction <- lmer(log(specnumber) ~ Species:GDD_5C + (1 |
Plant_ID), data = asv_scaled_noPlants_Phen_filt_LMM)
# Calculate marginal R-squared for `Species`
specnumber_marginal_r_squared_interaction <- r.squaredGLMM(lmm_model_specnumber_interaction,
mu0 = "fixed")
print(specnumber_marginal_r_squared_interaction)
## R2m R2c
## [1,] 0.09887173 0.3248731
library(stats)
# install.packages('agricolae')
library(agricolae)
shapiro.test(asv_scaled_noPlants_Phen_filt_LMM$specnumber)
##
## Shapiro-Wilk normality test
##
## data: asv_scaled_noPlants_Phen_filt_LMM$specnumber
## W = 0.90336, p-value = 4.696e-05
# p<0.05 --> thus, NOT normal; must do Kruskal-Wallis, followed by Wilcox
# pairwise comparisons
kruskal.test(asv_scaled_noPlants_Phen_filt_LMM$specnumber ~ asv_scaled_noPlants_Phen_filt_LMM$Species)
##
## Kruskal-Wallis rank sum test
##
## data: asv_scaled_noPlants_Phen_filt_LMM$specnumber by asv_scaled_noPlants_Phen_filt_LMM$Species
## Kruskal-Wallis chi-squared = 1.2842, df = 1, p-value = 0.2571
In this case, the p-value is 0.2595. Since the p-value is greater than the common significance level of 0.05, we fail to reject the null hypothesis. Therefore, there is not enough evidence to suggest that there are significant differences in the medians of the groups based on the variable “specnumber” for the different levels of the “Species” variable.
In other words, the Kruskal-Wallis test does not provide strong evidence to conclude that the distributions of “specnumber” are significantly different among the different species in the dataset.
Please note that the Kruskal-Wallis test only tells you that there are differences among the groups, but it does not indicate which groups are different from each other. If you want to identify specific differences between groups, you may need to perform post hoc tests, such as the Dunn test or the Conover-Iman test, to make pairwise comparisons. These post hoc tests account for multiple comparisons and help identify which specific groups differ significantly from each other.
pairwise.wilcox.test(asv_scaled_noPlants_Phen_filt_LMM$specnumber, asv_scaled_noPlants_Phen_filt_LMM$Species,
p.adj = "bonferroni")
##
## Pairwise comparisons using Wilcoxon rank sum test with continuity correction
##
## data: asv_scaled_noPlants_Phen_filt_LMM$specnumber and asv_scaled_noPlants_Phen_filt_LMM$Species
##
## Betula_populifolia
## Populus_tremuloides 0.26
##
## P value adjustment method: bonferroni
Since the p-value (0.26) is greater than the significance level (commonly set at 0.05), we fail to reject the null hypothesis. Therefore, there is not enough evidence to suggest that there are significant differences in the distribution of “specnumber” between “Betula populifolia” and “Populus tremuloides.”
kruskal.test(asv_scaled_noPlants_Phen_filt_LMM$specnumber ~ asv_scaled_noPlants_Phen_filt_LMM$GDD_5C)
##
## Kruskal-Wallis rank sum test
##
## data: asv_scaled_noPlants_Phen_filt_LMM$specnumber by asv_scaled_noPlants_Phen_filt_LMM$GDD_5C
## Kruskal-Wallis chi-squared = 5.6556, df = 6, p-value = 0.4629
In this case, the p-value is 0.4491. Since the p-value is greater than the common significance level of 0.05, we fail to reject the null hypothesis. Therefore, there is not enough evidence to suggest that there are significant differences in the medians of the groups based on the variable “specnumber” for the different levels of the “GDDs” variable.
In other words, the Kruskal-Wallis test does not provide strong evidence to conclude that the distributions of “specnumber” are significantly different among the different GDDs in the dataset.
library(dplyr)
library(purrr)
# For INTERspecific variation, we probably want to interaction p-value, so
# probably do it this way with Wilcox test like this:
# Group data by Growing-Degree-Days-5C and perform Wilcoxon test for each group
wilcox_specnumber <- asv_scaled_noPlants_Phen_filt_LMM %>%
group_by(GDD_5C) %>%
nest() %>%
mutate(wilcox_specnumber = map(data, ~wilcox.test(specnumber ~ Species, data = .x))) %>%
mutate(p_value = map_dbl(wilcox_specnumber, ~.x$p.value))
## Warning in wilcox.test.default(x = DATA[[1L]], y = DATA[[2L]], ...): cannot
## compute exact p-value with ties
## Warning in wilcox.test.default(x = DATA[[1L]], y = DATA[[2L]], ...): cannot
## compute exact p-value with ties
# Display the results
print(wilcox_specnumber)
## # A tibble: 7 × 4
## # Groups: GDD_5C [7]
## GDD_5C data wilcox_specnumber p_value
## <dbl> <list> <list> <dbl>
## 1 1087 <tibble [11 × 3,820]> <htest> 0.126
## 2 1992 <tibble [10 × 3,820]> <htest> 0.421
## 3 437 <tibble [10 × 3,820]> <htest> 0.142
## 4 605 <tibble [10 × 3,820]> <htest> 0.00794
## 5 2219 <tibble [10 × 3,820]> <htest> 0.841
## 6 1606 <tibble [10 × 3,820]> <htest> 0.674
## 7 2140 <tibble [10 × 3,820]> <htest> 1
# install.packages('urca')
library(urca)
# Perform KPSS test
kpss_specnumber <- ur.kpss(asv_scaled_noPlants_Phen_filt_LMM$specnumber)
# summary of KPSS Test
summary(kpss_specnumber)
##
## #######################
## # KPSS Unit Root Test #
## #######################
##
## Test is of type: mu with 3 lags.
##
## Value of test-statistic is: 0.1611
##
## Critical value for a significance level of:
## 10pct 5pct 2.5pct 1pct
## critical values 0.347 0.463 0.574 0.739
# ASV richness BEWTEEN SPECIES over GDDs is STATIONARY!
#-------------------------------------------------------------------------
# Homogeneity of Slopes faceted by 'Species'
#-------------------------------------------------------------------------
## NOTE: Homoegenity of slopes is just looking at the data but not the actual
## results, plus there are no error bars, so it's telling if there's
## potentially an interaction, but not definitely whether or not. Do NOT rely
## on this, especially b/c no error bars. Traditional ANCOVA moving away from
## this?
#-------------------------------------------------------------------------
# (a) x=`GDD_5C`
#-------------------------------------------------------------------------
# Untransformed:
levels = c("Betula_populifolia", "Populus_tremuloides")
myplot_shannon <- ggplot(data = asv_scaled_noPlants_Phen_filt_LMM, aes(x = GDD_5C,
y = alphaDiv)) + facet_grid(. ~ Species) + geom_point() + theme(panel.border = element_rect(color = "black",
fill = NA, size = 1))
myplot_shannon <- myplot_shannon + stat_smooth(method = lm, se = FALSE) + stat_smooth(se = FALSE,
color = "red")
labs(y = expression(~alphaDiv), x = expression(~GDD_5C))
## $y
## expression(~alphaDiv)
##
## $x
## expression(~GDD_5C)
##
## attr(,"class")
## [1] "labels"
myplot_shannon
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
# Save the plot
ggsave("myplot_shannon.jpg", plot = myplot_shannon, width = 8, height = 6, units = "in",
dpi = 300)
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
#-------------------------------------------------------------------------
# (a) x=`GDD_5C`
#-------------------------------------------------------------------------
levels = c("Betula_populifolia", "Populus_tremuloides")
myplot_shannon2 <- ggplot(data = asv_scaled_noPlants_Phen_filt_LMM, aes(x = GDD_5C,
y = sqrt(alphaDiv))) + facet_grid(. ~ Species) + geom_point()
myplot_shannon2 <- myplot_shannon2 + stat_smooth(method = lm, se = FALSE) + stat_smooth(se = FALSE,
color = "red") + labs(y = expression(~sqrt(alphaDiv)), x = expression(~GDD_5C))
myplot_shannon2
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
library(ggplot2)
myplot_shannon3 <- ggplot(data = asv_scaled_noPlants_Phen_filt_LMM, aes(x = GDD_5C,
y = sqrt(alphaDiv))) + facet_grid(. ~ Species) + geom_point() + stat_smooth(method = lm,
se = FALSE) + stat_smooth(se = FALSE, color = "red") + labs(y = expression(~sqrt(alphaDiv)),
x = expression(~GDD_5C)) + geom_text(aes(x = Inf, y = -Inf, label = paste("R-squared: ",
round(summary(lm(sqrt(alphaDiv) ~ GDD_5C, data = asv_scaled_noPlants_Phen_filt_LMM))$r.squared,
3))), hjust = 1, vjust = 0, color = "blue", size = 3)
myplot_shannon3
## Warning in geom_text(aes(x = Inf, y = -Inf, label = paste("R-squared: ", : All aesthetics have length 1, but the data has 71 rows.
## ℹ Please consider using `annotate()` or provide this layer with data containing
## a single row.
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
# Arrange the plots in a grid
homogeneity_plots_untransformed <- arrangeGrob(myplot_specnumber, myplot_shannon,
ncol = 1, nrow = 2)
# Save the combined plot
ggsave("homogeneity_plots_untransformed.jpg", homogeneity_plots_untransformed, width = 7,
height = 7, units = "in", dpi = 600) # Adjust width and height as needed
#-------------------------------------------------------------------------
# Visualize data with a Scatterplot Matrix
#-------------------------------------------------------------------------
# To evaluate not only linearity, but also collinearity; r.e. lecture on
# Multiple Regression (lec. 16/17) slide 46
plot <- scatterplotMatrix(~alphaDiv + Species + GDD_5C, regLine = TRUE, smooth = TRUE,
diagonal = TRUE, data = asv_scaled_noPlants_Phen_filt_LMM)
# Install and load necessary packages install.packages('lmerTest')
# install.packages('lme4')
library(lmerTest)
library(lme4)
# Fit the linear mixed-effects model
lmm_model_shannon1 <- lmer(alphaDiv ~ Species + GDD_5C + Species:GDD_5C + (1 | Plant_ID),
data = asv_scaled_noPlants_Phen_filt_LMM)
# Obtain summary of the LMM with p-values
summary(lmm_model_shannon1)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: alphaDiv ~ Species + GDD_5C + Species:GDD_5C + (1 | Plant_ID)
## Data: asv_scaled_noPlants_Phen_filt_LMM
##
## REML criterion at convergence: 174.8
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -4.2010 -0.4455 0.0695 0.6617 1.5385
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0.04487 0.2118
## Residual 0.40653 0.6376
## Number of obs: 71, groups: Plant_ID, 10
##
## Fixed effects:
## Estimate Std. Error df t value
## (Intercept) 2.514e+00 2.691e-01 5.353e+01 9.341
## SpeciesPopulus_tremuloides 9.057e-01 3.788e-01 5.310e+01 2.391
## GDD_5C -1.956e-05 1.580e-04 5.901e+01 -0.124
## SpeciesPopulus_tremuloides:GDD_5C -2.824e-06 2.231e-04 5.904e+01 -0.013
## Pr(>|t|)
## (Intercept) 7.84e-13 ***
## SpeciesPopulus_tremuloides 0.0204 *
## GDD_5C 0.9019
## SpeciesPopulus_tremuloides:GDD_5C 0.9899
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) SpcsP_ GDD_5C
## SpcsPpls_tr -0.710
## GDD_5C -0.846 0.601
## SpP_:GDD_5C 0.599 -0.846 -0.708
# Fit the linear mixed-effects model
lmm_model_shannon2 <- lmer(sqrt(alphaDiv) ~ Species + GDD_5C + Species:GDD_5C + (1 |
Plant_ID), data = asv_scaled_noPlants_Phen_filt_LMM)
# Obtain summary of the LMM with p-values
summary(lmm_model_shannon2)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: sqrt(alphaDiv) ~ Species + GDD_5C + Species:GDD_5C + (1 | Plant_ID)
## Data: asv_scaled_noPlants_Phen_filt_LMM
##
## REML criterion at convergence: 28.5
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -4.8802 -0.3413 0.1393 0.5806 1.3469
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0.005198 0.07209
## Residual 0.045732 0.21385
## Number of obs: 71, groups: Plant_ID, 10
##
## Fixed effects:
## Estimate Std. Error df t value
## (Intercept) 1.576e+00 9.042e-02 5.314e+01 17.430
## SpeciesPopulus_tremuloides 2.641e-01 1.273e-01 5.271e+01 2.075
## GDD_5C -8.851e-06 5.299e-05 5.899e+01 -0.167
## SpeciesPopulus_tremuloides:GDD_5C -1.160e-06 7.481e-05 5.901e+01 -0.015
## Pr(>|t|)
## (Intercept) <2e-16 ***
## SpeciesPopulus_tremuloides 0.0429 *
## GDD_5C 0.8679
## SpeciesPopulus_tremuloides:GDD_5C 0.9877
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) SpcsP_ GDD_5C
## SpcsPpls_tr -0.710
## GDD_5C -0.844 0.600
## SpP_:GDD_5C 0.598 -0.844 -0.708
# Fit the linear mixed-effects model
lmm_model_shannon2_plantid_month <- lmer(sqrt(alphaDiv) ~ Species + GDD_5C + Species:GDD_5C +
(1 | Plant_ID) + (1 | `Collection-Month`), data = asv_scaled_noPlants_Phen_filt_LMM)
# Obtain summary of the LMM with p-values
summary(lmm_model_shannon2_plantid_month)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: sqrt(alphaDiv) ~ Species + GDD_5C + Species:GDD_5C + (1 | Plant_ID) +
## (1 | `Collection-Month`)
## Data: asv_scaled_noPlants_Phen_filt_LMM
##
## REML criterion at convergence: 28.3
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -4.7440 -0.2994 0.1266 0.5494 1.4053
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0.005330 0.07301
## Collection-Month (Intercept) 0.001873 0.04328
## Residual 0.044577 0.21113
## Number of obs: 71, groups: Plant_ID, 10; Collection-Month, 5
##
## Fixed effects:
## Estimate Std. Error df t value
## (Intercept) 1.578e+00 1.030e-01 5.593e+00 15.328
## SpeciesPopulus_tremuloides 2.635e-01 1.261e-01 5.073e+01 2.089
## GDD_5C -1.270e-05 6.094e-05 4.950e+00 -0.208
## SpeciesPopulus_tremuloides:GDD_5C -9.167e-07 7.386e-05 5.587e+01 -0.012
## Pr(>|t|)
## (Intercept) 8.79e-06 ***
## SpeciesPopulus_tremuloides 0.0417 *
## GDD_5C 0.8432
## SpeciesPopulus_tremuloides:GDD_5C 0.9901
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) SpcsP_ GDD_5C
## SpcsPpls_tr -0.619
## GDD_5C -0.861 0.514
## SpP_:GDD_5C 0.519 -0.841 -0.609
# Fit the linear mixed-effects model
lmm_model_shannon2_month <- lmer(sqrt(alphaDiv) ~ Species + GDD_5C + Species:GDD_5C +
(1 | `Collection-Month`), data = asv_scaled_noPlants_Phen_filt_LMM)
# Obtain summary of the LMM with p-values
summary(lmm_model_shannon2_month)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## sqrt(alphaDiv) ~ Species + GDD_5C + Species:GDD_5C + (1 | `Collection-Month`)
## Data: asv_scaled_noPlants_Phen_filt_LMM
##
## REML criterion at convergence: 29.8
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -4.8975 -0.3190 0.1538 0.5902 1.4405
##
## Random effects:
## Groups Name Variance Std.Dev.
## Collection-Month (Intercept) 0.001532 0.03913
## Residual 0.049286 0.22200
## Number of obs: 71, groups: Collection-Month, 5
##
## Fixed effects:
## Estimate Std. Error df t value
## (Intercept) 1.578e+00 9.905e-02 4.749e+00 15.931
## SpeciesPopulus_tremuloides 2.660e-01 1.234e-01 6.380e+01 2.156
## GDD_5C -1.209e-05 6.188e-05 5.063e+00 -0.195
## SpeciesPopulus_tremuloides:GDD_5C -1.824e-06 7.766e-05 6.374e+01 -0.023
## Pr(>|t|)
## (Intercept) 2.64e-05 ***
## SpeciesPopulus_tremuloides 0.0349 *
## GDD_5C 0.8527
## SpeciesPopulus_tremuloides:GDD_5C 0.9813
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) SpcsP_ GDD_5C
## SpcsPpls_tr -0.631
## GDD_5C -0.907 0.572
## SpP_:GDD_5C 0.568 -0.904 -0.630
# Fit the linear mixed-effects model
lmm_model_shannon3 <- lmer(I(alphaDiv^2) ~ Species + GDD_5C + Species:GDD_5C + (1 |
Plant_ID), data = asv_scaled_noPlants_Phen_filt_LMM)
# Obtain summary of the LMM with p-values
summary(lmm_model_shannon3)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: I(alphaDiv^2) ~ Species + GDD_5C + Species:GDD_5C + (1 | Plant_ID)
## Data: asv_scaled_noPlants_Phen_filt_LMM
##
## REML criterion at convergence: 396.2
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.2457 -0.6218 -0.0106 0.6994 2.1095
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0.8564 0.9254
## Residual 11.2726 3.3575
## Number of obs: 71, groups: Plant_ID, 10
##
## Fixed effects:
## Estimate Std. Error df t value
## (Intercept) 6.603e+00 1.389e+00 5.735e+01 4.753
## SpeciesPopulus_tremuloides 5.410e+00 1.955e+00 5.696e+01 2.767
## GDD_5C -3.287e-05 8.320e-04 5.910e+01 -0.040
## SpeciesPopulus_tremuloides:GDD_5C -1.682e-05 1.175e-03 5.913e+01 -0.014
## Pr(>|t|)
## (Intercept) 1.39e-05 ***
## SpeciesPopulus_tremuloides 0.00762 **
## GDD_5C 0.96862
## SpeciesPopulus_tremuloides:GDD_5C 0.98862
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) SpcsP_ GDD_5C
## SpcsPpls_tr -0.711
## GDD_5C -0.863 0.613
## SpP_:GDD_5C 0.611 -0.863 -0.708
# Fit the linear mixed-effects model
lmm_model_shannon4 <- lmer((1/alphaDiv) ~ Species + GDD_5C + Species:GDD_5C + (1 |
Plant_ID), data = asv_scaled_noPlants_Phen_filt_LMM)
# Obtain summary of the LMM with p-values
summary(lmm_model_shannon4)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: (1/alphaDiv) ~ Species + GDD_5C + Species:GDD_5C + (1 | Plant_ID)
## Data: asv_scaled_noPlants_Phen_filt_LMM
##
## REML criterion at convergence: 34.3
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -0.6613 -0.3625 -0.1773 -0.0300 7.0954
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0.002321 0.04818
## Residual 0.051720 0.22742
## Number of obs: 71, groups: Plant_ID, 10
##
## Fixed effects:
## Estimate Std. Error df t value
## (Intercept) 4.184e-01 9.239e-02 6.050e+01 4.529
## SpeciesPopulus_tremuloides -1.013e-01 1.300e-01 6.015e+01 -0.779
## GDD_5C 1.112e-05 5.636e-05 5.894e+01 0.197
## SpeciesPopulus_tremuloides:GDD_5C 6.554e-06 7.956e-05 5.898e+01 0.082
## Pr(>|t|)
## (Intercept) 2.84e-05 ***
## SpeciesPopulus_tremuloides 0.439
## GDD_5C 0.844
## SpeciesPopulus_tremuloides:GDD_5C 0.935
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) SpcsP_ GDD_5C
## SpcsPpls_tr -0.711
## GDD_5C -0.879 0.625
## SpP_:GDD_5C 0.623 -0.879 -0.708
# Fit the linear mixed-effects model
lmm_model_shannon5 <- lmer(sqrt(alphaDiv) ~ Species + I(GDD_5C^3) + Species:I(GDD_5C^3) +
(1 | Plant_ID), data = asv_scaled_noPlants_Phen_filt_LMM)
## Warning: Some predictor variables are on very different scales: consider
## rescaling
## Warning: Some predictor variables are on very different scales: consider
## rescaling
# Obtain summary of the LMM with p-values
summary(lmm_model_shannon5)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: sqrt(alphaDiv) ~ Species + I(GDD_5C^3) + Species:I(GDD_5C^3) +
## (1 | Plant_ID)
## Data: asv_scaled_noPlants_Phen_filt_LMM
##
## REML criterion at convergence: 91
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -4.8838 -0.3371 0.1559 0.4821 1.3550
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0.005256 0.0725
## Residual 0.045604 0.2136
## Number of obs: 71, groups: Plant_ID, 10
##
## Fixed effects:
## Estimate Std. Error df t value
## (Intercept) 1.577e+00 6.380e-02 2.255e+01 24.720
## SpeciesPopulus_tremuloides 2.366e-01 8.949e-02 2.188e+01 2.644
## I(GDD_5C^3) -2.787e-12 8.438e-12 5.899e+01 -0.330
## SpeciesPopulus_tremuloides:I(GDD_5C^3) 5.334e-12 1.188e-11 5.905e+01 0.449
## Pr(>|t|)
## (Intercept) <2e-16 ***
## SpeciesPopulus_tremuloides 0.0149 *
## I(GDD_5C^3) 0.7424
## SpeciesPopulus_tremuloides:I(GDD_5C^3) 0.6550
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) SpcsP_ I(GDD_
## SpcsPpls_tr -0.713
## I(GDD_5C^3) -0.649 0.463
## SP_:I(GDD_5 0.461 -0.645 -0.710
## fit warnings:
## Some predictor variables are on very different scales: consider rescaling
# Fit the linear mixed-effects model
lmm_model_shannon6 <- lmer(sqrt(alphaDiv) ~ Species + I(GDD_5C^2) + Species:I(GDD_5C^2) +
(1 | Plant_ID), data = asv_scaled_noPlants_Phen_filt_LMM)
## Warning: Some predictor variables are on very different scales: consider
## rescaling
## Warning: Some predictor variables are on very different scales: consider
## rescaling
# Obtain summary of the LMM with p-values
summary(lmm_model_shannon6)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: sqrt(alphaDiv) ~ Species + I(GDD_5C^2) + Species:I(GDD_5C^2) +
## (1 | Plant_ID)
## Data: asv_scaled_noPlants_Phen_filt_LMM
##
## REML criterion at convergence: 60.2
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -4.8885 -0.3341 0.1278 0.5318 1.3480
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0.005216 0.07222
## Residual 0.045719 0.21382
## Number of obs: 71, groups: Plant_ID, 10
##
## Fixed effects:
## Estimate Std. Error df t value
## (Intercept) 1.576e+00 6.937e-02 2.950e+01 22.717
## SpeciesPopulus_tremuloides 2.466e-01 9.741e-02 2.880e+01 2.532
## I(GDD_5C^2) -4.964e-09 1.953e-08 5.899e+01 -0.254
## SpeciesPopulus_tremuloides:I(GDD_5C^2) 6.299e-09 2.752e-08 5.904e+01 0.229
## Pr(>|t|)
## (Intercept) <2e-16 ***
## SpeciesPopulus_tremuloides 0.0171 *
## I(GDD_5C^2) 0.8002
## SpeciesPopulus_tremuloides:I(GDD_5C^2) 0.8198
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) SpcsP_ I(GDD_
## SpcsPpls_tr -0.712
## I(GDD_5C^2) -0.715 0.510
## SP_:I(GDD_5 0.508 -0.713 -0.710
## fit warnings:
## Some predictor variables are on very different scales: consider rescaling
# Fit the linear mixed-effects model
lmm_model_shannon7 <- lmer(alphaDiv ~ Species + I(GDD_5C^2) + Species:I(GDD_5C^2) +
(1 | Plant_ID), data = asv_scaled_noPlants_Phen_filt_LMM)
## Warning: Some predictor variables are on very different scales: consider
## rescaling
## Warning: Some predictor variables are on very different scales: consider
## rescaling
# Obtain summary of the LMM with p-values
summary(lmm_model_shannon7)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: alphaDiv ~ Species + I(GDD_5C^2) + Species:I(GDD_5C^2) + (1 |
## Plant_ID)
## Data: asv_scaled_noPlants_Phen_filt_LMM
##
## REML criterion at convergence: 206.4
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -4.2078 -0.4364 0.0957 0.6176 1.5214
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0.04505 0.2123
## Residual 0.40629 0.6374
## Number of obs: 71, groups: Plant_ID, 10
##
## Fixed effects:
## Estimate Std. Error df t value
## (Intercept) 2.519e+00 2.062e-01 2.985e+01 12.217
## SpeciesPopulus_tremuloides 8.557e-01 2.895e-01 2.914e+01 2.956
## I(GDD_5C^2) -1.306e-08 5.822e-08 5.901e+01 -0.224
## SpeciesPopulus_tremuloides:I(GDD_5C^2) 1.821e-08 8.204e-08 5.906e+01 0.222
## Pr(>|t|)
## (Intercept) 3.84e-13 ***
## SpeciesPopulus_tremuloides 0.00612 **
## I(GDD_5C^2) 0.82322
## SpeciesPopulus_tremuloides:I(GDD_5C^2) 0.82507
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) SpcsP_ I(GDD_
## SpcsPpls_tr -0.712
## I(GDD_5C^2) -0.718 0.511
## SP_:I(GDD_5 0.509 -0.715 -0.710
## fit warnings:
## Some predictor variables are on very different scales: consider rescaling
# Fit the linear mixed-effects model
lmm_model_shannon8 <- lmer(alphaDiv ~ Species + I(GDD_5C^3) + Species:I(GDD_5C^3) +
(1 | Plant_ID), data = asv_scaled_noPlants_Phen_filt_LMM)
## Warning: Some predictor variables are on very different scales: consider
## rescaling
## Warning: Some predictor variables are on very different scales: consider
## rescaling
# Obtain summary of the LMM with p-values
summary(lmm_model_shannon8)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: alphaDiv ~ Species + I(GDD_5C^3) + Species:I(GDD_5C^3) + (1 |
## Plant_ID)
## Data: asv_scaled_noPlants_Phen_filt_LMM
##
## REML criterion at convergence: 237.3
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -4.2022 -0.4348 0.0972 0.5703 1.5053
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0.04541 0.2131
## Residual 0.40527 0.6366
## Number of obs: 71, groups: Plant_ID, 10
##
## Fixed effects:
## Estimate Std. Error df t value
## (Intercept) 2.524e+00 1.895e-01 2.281e+01 13.321
## SpeciesPopulus_tremuloides 8.265e-01 2.658e-01 2.213e+01 3.109
## I(GDD_5C^3) -7.880e-12 2.515e-11 5.901e+01 -0.313
## SpeciesPopulus_tremuloides:I(GDD_5C^3) 1.548e-11 3.541e-11 5.908e+01 0.437
## Pr(>|t|)
## (Intercept) 3.04e-12 ***
## SpeciesPopulus_tremuloides 0.00509 **
## I(GDD_5C^3) 0.75520
## SpeciesPopulus_tremuloides:I(GDD_5C^3) 0.66351
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) SpcsP_ I(GDD_
## SpcsPpls_tr -0.713
## I(GDD_5C^3) -0.652 0.465
## SP_:I(GDD_5 0.463 -0.648 -0.710
## fit warnings:
## Some predictor variables are on very different scales: consider rescaling
#-----------------------------------------------------------------------------
## ANCOVA
#-----------------------------------------------------------------------------
# Perform ANCOVA
ancova_shannon <- lm(sqrt(alphaDiv) ~ Species + GDD_5C + Species:GDD_5C, data = asv_scaled_noPlants_Phen_filt_LMM)
Anova(ancova_shannon, type = 3)
## Anova Table (Type III tests)
##
## Response: sqrt(alphaDiv)
## Sum Sq Df F value Pr(>F)
## (Intercept) 15.9179 1 317.5151 < 2e-16 ***
## Species 0.2301 1 4.5904 0.03579 *
## GDD_5C 0.0013 1 0.0254 0.87374
## Species:GDD_5C 0.0000 1 0.0007 0.97945
## Residuals 3.3589 67
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(ancova_shannon)
##
## Call:
## lm(formula = sqrt(alphaDiv) ~ Species + GDD_5C + Species:GDD_5C,
## data = asv_scaled_noPlants_Phen_filt_LMM)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.11968 -0.07651 0.03582 0.13686 0.32937
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.576e+00 8.845e-02 17.819 <2e-16 ***
## SpeciesPopulus_tremuloides 2.665e-01 1.244e-01 2.143 0.0358 *
## GDD_5C -8.851e-06 5.548e-05 -0.160 0.8737
## SpeciesPopulus_tremuloides:GDD_5C -2.025e-06 7.832e-05 -0.026 0.9795
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.2239 on 67 degrees of freedom
## Multiple R-squared: 0.2692, Adjusted R-squared: 0.2365
## F-statistic: 8.227 on 3 and 67 DF, p-value: 9.732e-05
# Adjusted R^2 = 0.3016
#-------------------------------------------------------------------------
## Compare Model Fits with anova():
#-------------------------------------------------------------------------
# Compare 'model.final2' with ANCOVA model:
anova(lmm_model_shannon1, lmm_model_shannon2, lmm_model_shannon3, lmm_model_shannon4,
ancova_shannon, lmm_model_shannon2_month, lmm_model_shannon2_plantid_month, lmm_model_shannon5,
lmm_model_shannon6, lmm_model_shannon7, lmm_model_shannon8)
## refitting model(s) with ML (instead of REML)
## Data: asv_scaled_noPlants_Phen_filt_LMM
## Models:
## ancova_shannon: sqrt(alphaDiv) ~ Species + GDD_5C + Species:GDD_5C
## lmm_model_shannon1: alphaDiv ~ Species + GDD_5C + Species:GDD_5C + (1 | Plant_ID)
## lmm_model_shannon2: sqrt(alphaDiv) ~ Species + GDD_5C + Species:GDD_5C + (1 | Plant_ID)
## lmm_model_shannon3: I(alphaDiv^2) ~ Species + GDD_5C + Species:GDD_5C + (1 | Plant_ID)
## lmm_model_shannon4: (1/alphaDiv) ~ Species + GDD_5C + Species:GDD_5C + (1 | Plant_ID)
## lmm_model_shannon2_month: sqrt(alphaDiv) ~ Species + GDD_5C + Species:GDD_5C + (1 | `Collection-Month`)
## lmm_model_shannon5: sqrt(alphaDiv) ~ Species + I(GDD_5C^3) + Species:I(GDD_5C^3) + (1 | Plant_ID)
## lmm_model_shannon6: sqrt(alphaDiv) ~ Species + I(GDD_5C^2) + Species:I(GDD_5C^2) + (1 | Plant_ID)
## lmm_model_shannon7: alphaDiv ~ Species + I(GDD_5C^2) + Species:I(GDD_5C^2) + (1 | Plant_ID)
## lmm_model_shannon8: alphaDiv ~ Species + I(GDD_5C^3) + Species:I(GDD_5C^3) + (1 | Plant_ID)
## lmm_model_shannon2_plantid_month: sqrt(alphaDiv) ~ Species + GDD_5C + Species:GDD_5C + (1 | Plant_ID) + (1 | `Collection-Month`)
## npar AIC BIC logLik deviance Chisq
## ancova_shannon 5 -5.14 6.18 7.568 -15.14
## lmm_model_shannon1 6 151.10 164.68 -69.551 139.10 0.0000
## lmm_model_shannon2 6 -3.89 9.68 7.947 -15.89 154.9962
## lmm_model_shannon3 6 385.53 399.10 -186.764 373.53 0.0000
## lmm_model_shannon4 6 1.69 15.27 5.154 -10.31 383.8353
## lmm_model_shannon2_month 6 -3.14 10.44 7.568 -15.14 4.8291
## lmm_model_shannon5 6 -4.03 9.55 8.015 -16.03 0.8933
## lmm_model_shannon6 6 -3.90 9.68 7.948 -15.90 0.0000
## lmm_model_shannon7 6 151.08 164.66 -69.541 139.08 0.0000
## lmm_model_shannon8 6 150.95 164.52 -69.474 138.95 0.1335
## lmm_model_shannon2_plantid_month 7 -1.89 13.95 7.947 -15.89 154.8417
## Df Pr(>Chisq)
## ancova_shannon
## lmm_model_shannon1 1 1
## lmm_model_shannon2 0
## lmm_model_shannon3 0
## lmm_model_shannon4 0
## lmm_model_shannon2_month 0
## lmm_model_shannon5 0
## lmm_model_shannon6 0
## lmm_model_shannon7 0
## lmm_model_shannon8 0
## lmm_model_shannon2_plantid_month 1 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Slightly lower AIC and BIC for `lmm_model_shannon2` than
# `lmm_model_shannon2_month` with sqrt-transformation, higher logLik, and also
# lower deviance, etc.
#-------------------------------------------------------------------------
## To be sure of my model, let's run formal diagnostics:
#-------------------------------------------------------------------------
# Formal Test of Normality (Shapiro-Wilks)
#-------------------------------------------------------------------------
shapiro.test(residuals(lmm_model_shannon1)) # p=0.0001196 -> NOT Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_shannon1)
## W = 0.91352, p-value = 0.0001241
shapiro.test(residuals(lmm_model_shannon2)) # p=2.494e-07 -> Even LESS Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_shannon2)
## W = 0.83847, p-value = 2.533e-07
shapiro.test(residuals(lmm_model_shannon3)) # p=0.259 -> Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_shannon3)
## W = 0.97897, p-value = 0.2788
shapiro.test(residuals(lmm_model_shannon4)) # p=3.892e-15 -> WORST for Normality!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_shannon4)
## W = 0.42903, p-value = 3.869e-15
shapiro.test(residuals(ancova_shannon)) # p=0.0001316 -> NOT Normal
##
## Shapiro-Wilk normality test
##
## data: residuals(ancova_shannon)
## W = 0.84117, p-value = 3.065e-07
shapiro.test(residuals(lmm_model_shannon2_month)) # p=4.531e-07 -> NOT Normal
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_shannon2_month)
## W = 0.84741, p-value = 4.795e-07
shapiro.test(residuals(lmm_model_shannon2_plantid_month)) # p=4.531e-07 -> NOT Normal
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_shannon2_plantid_month)
## W = 0.84563, p-value = 4.216e-07
shapiro.test(residuals(lmm_model_shannon5))
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_shannon5)
## W = 0.83922, p-value = 2.67e-07
shapiro.test(residuals(lmm_model_shannon6))
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_shannon6)
## W = 0.83794, p-value = 2.441e-07
shapiro.test(residuals(lmm_model_shannon7))
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_shannon7)
## W = 0.91346, p-value = 0.0001234
shapiro.test(residuals(lmm_model_shannon8))
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_shannon8)
## W = 0.91466, p-value = 0.000139
## Here, `lmm_model_shannon3` is the only model with normally distributed
## residuals.. but terrible residuals.
#-------------------------------------------------------------------------
## Check Diagnostic Statistics/Assumptions
#-------------------------------------------------------------------------
check_model(lmm_model_shannon1, check = c("pp_check", "normality", "vif", "linearity",
"homogeneity", "outliers"))
check_model(lmm_model_shannon2, check = c("pp_check", "normality", "vif", "linearity",
"homogeneity", "outliers"))
check_model(lmm_model_shannon3, check = c("pp_check", "normality", "vif", "linearity",
"homogeneity", "outliers"))
check_model(lmm_model_shannon4, check = c("pp_check", "normality", "vif", "linearity",
"homogeneity", "outliers"))
check_model(ancova_shannon)
check_model(lmm_model_shannon2_month, check = c("pp_check", "normality", "vif", "linearity",
"homogeneity", "outliers"))
check_model(lmm_model_shannon2_plantid_month, check = c("pp_check", "normality",
"vif", "linearity", "homogeneity", "outliers"))
check_model(lmm_model_shannon5, check = c("pp_check", "normality", "vif", "linearity",
"homogeneity", "outliers"))
check_model(lmm_model_shannon6, check = c("pp_check", "normality", "vif", "linearity",
"homogeneity", "outliers"))
check_model(lmm_model_shannon7, check = c("pp_check", "normality", "vif", "linearity",
"homogeneity", "outliers"))
check_model(lmm_model_shannon8, check = c("pp_check", "normality", "vif", "linearity",
"homogeneity", "outliers"))
## `lmm_model_shannon1` and `lmm_model_shannon2` don't differ much;
## `lmm_model_shannon2` likely best still.
## For ANCOVA, residuals are terrible looking.
## Since AIC and BIC, plus others, are substantially better for
## `lmm_model_shannon2` than `lmm_model_shannon1`, we choose
## `lmm_model_shannon2` (square-root transformed).
NOTE: lmm_model_shannon2 (i.e., sqrt
transformed) is best for diagnostics above.
# ANOVA of LMM model using `car` package.
library(car)
anova_lmm_shannon2 <- Anova(lmm_model_shannon2)
anova_lmm_shannon2_month <- Anova(lmm_model_shannon2_month)
anova_lmm_shannon2_plantid_month <- Anova(lmm_model_shannon2_plantid_month)
summary(anova_lmm_shannon2)
## Chisq Df Pr(>Chisq)
## Min. : 0.00024 Min. :1 Min. :0.0001202
## 1st Qu.: 0.03191 1st Qu.:1 1st Qu.:0.4005164
## Median : 0.06359 Median :1 Median :0.8009127
## Mean : 4.95122 Mean :1 Mean :0.5962221
## 3rd Qu.: 7.42671 3rd Qu.:1 3rd Qu.:0.8942731
## Max. :14.78983 Max. :1 Max. :0.9876335
summary(anova_lmm_shannon2_month)
## Chisq Df Pr(>Chisq)
## Min. : 0.000552 Min. :1 Min. :0.0000006
## 1st Qu.: 0.036922 1st Qu.:1 1st Qu.:0.3933017
## Median : 0.073292 Median :1 Median :0.7866028
## Mean : 8.345332 Mean :1 Mean :0.5892886
## 3rd Qu.:12.517722 3rd Qu.:1 3rd Qu.:0.8839325
## Max. :24.962153 Max. :1 Max. :0.9812623
summary(anova_lmm_shannon2_plantid_month)
## Chisq Df Pr(>Chisq)
## Min. : 0.000154 Min. :1 Min. :0.0001202
## 1st Qu.: 0.037156 1st Qu.:1 1st Qu.:0.3927478
## Median : 0.074159 Median :1 Median :0.7853754
## Mean : 4.954703 Mean :1 Mean :0.5918644
## 3rd Qu.: 7.431978 3rd Qu.:1 3rd Qu.:0.8877364
## Max. :14.789797 Max. :1 Max. :0.9900975
## Supports `lmm_model_shannon2` as best fit.
################################################################################ FINAL
################################################################################ CHOICE:
################################################################################ `lmm_model_shannon2`
################################################################################ (sqrt
################################################################################ transformed
################################################################################ response
################################################################################ variable)
# Fit the linear mixed-effects model
lmm_model_shannon2 <- lmer(sqrt(alphaDiv) ~ Species + GDD_5C + Species:GDD_5C + (1 |
Plant_ID), data = asv_scaled_noPlants_Phen_filt_LMM)
# Obtain summary of the LMM with p-values
summary(lmm_model_shannon2)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: sqrt(alphaDiv) ~ Species + GDD_5C + Species:GDD_5C + (1 | Plant_ID)
## Data: asv_scaled_noPlants_Phen_filt_LMM
##
## REML criterion at convergence: 28.5
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -4.8802 -0.3413 0.1393 0.5806 1.3469
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0.005198 0.07209
## Residual 0.045732 0.21385
## Number of obs: 71, groups: Plant_ID, 10
##
## Fixed effects:
## Estimate Std. Error df t value
## (Intercept) 1.576e+00 9.042e-02 5.314e+01 17.430
## SpeciesPopulus_tremuloides 2.641e-01 1.273e-01 5.271e+01 2.075
## GDD_5C -8.851e-06 5.299e-05 5.899e+01 -0.167
## SpeciesPopulus_tremuloides:GDD_5C -1.160e-06 7.481e-05 5.901e+01 -0.015
## Pr(>|t|)
## (Intercept) <2e-16 ***
## SpeciesPopulus_tremuloides 0.0429 *
## GDD_5C 0.8679
## SpeciesPopulus_tremuloides:GDD_5C 0.9877
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) SpcsP_ GDD_5C
## SpcsPpls_tr -0.710
## GDD_5C -0.844 0.600
## SpP_:GDD_5C 0.598 -0.844 -0.708
# install.packages('MuMIn')
library(MuMIn)
# Calculate marginal R-squared for `lmm_model_shannon2`
shannon2_marginal_r_squared <- r.squaredGLMM(lmm_model_shannon2, mu0 = "fixed")
print(shannon2_marginal_r_squared)
## R2m R2c
## [1,] 0.2559408 0.331875
#--------------------------------------------------------------
## Marginal R^2 for `Species`
#--------------------------------------------------------------
# Fit `lmm_model_shannon2` with just `Species`
lmm_model_shannon2_sp <- lmer(sqrt(alphaDiv) ~ Species + (1 | Plant_ID), data = asv_scaled_noPlants_Phen_filt_LMM)
# Calculate marginal R-squared for `Species`
shannon2_marginal_r_squared_sp <- r.squaredGLMM(lmm_model_shannon2_sp, mu0 = "fixed")
print(shannon2_marginal_r_squared_sp)
## R2m R2c
## [1,] 0.260135 0.3407456
#--------------------------------------------------------------
## Marginal R^2 for `GDD_5C`
#--------------------------------------------------------------
# Fit `lmm_model_shannon2` with just `GDD_5C`
lmm_model_shannon2_gdd <- lmer(sqrt(alphaDiv) ~ GDD_5C + (1 | Plant_ID), data = asv_scaled_noPlants_Phen_filt_LMM)
# Calculate marginal R-squared for `GDD_5C`
shannon2_marginal_r_squared_gdd <- r.squaredGLMM(lmm_model_shannon2_gdd, mu0 = "fixed")
print(shannon2_marginal_r_squared_gdd)
## R2m R2c
## [1,] 0.0006062252 0.340029
#--------------------------------------------------------------
## Marginal R^2 for `Species:GDD_5C` interaction
#--------------------------------------------------------------
# Fit `lmm_model_shannon2` with just `Species:GDD_5C` interaction
lmm_model_shannon2_int <- lmer(sqrt(alphaDiv) ~ Species:GDD_5C + (1 | Plant_ID),
data = asv_scaled_noPlants_Phen_filt_LMM)
# Calculate marginal R-squared for `Species:GDD_5C` interaction
shannon2_marginal_r_squared_int <- r.squaredGLMM(lmm_model_shannon2_int, mu0 = "fixed")
print(shannon2_marginal_r_squared_int)
## R2m R2c
## [1,] 0.1588423 0.2625802
Shapiro Test (comparing independent groups wiht Shannon/ASV richness, must check if normally distrib.) –> Only specify column in which dataset is in (shaphiro.test(column), will only do on just one column); if normal, do ANOVA.
If not normal, Kruskal-Wallis test –> equivalence of ANOVA with non-parametric data. DO NOT use Tukey HSD, there is one that is equiavlent for non-parametric (can’t recall name).
In this case, once ANOVA is done, want to look at pairwise comparison –> this just says variance differs b/w groups, but don’t know where diffs are –> need Tukey HSD for ANOVA.
shapiro.test(asv_scaled_noPlants_Phen_filt_LMM$alphaDiv)
##
## Shapiro-Wilk normality test
##
## data: asv_scaled_noPlants_Phen_filt_LMM$alphaDiv
## W = 0.96566, p-value = 0.04904
Since p>0.05 means it IS normally distrib, then we would do ANOVA (parametric test).
But, if we are stricter/conservative and say it is NOT normally distrib., b/c p>0.05 is violated here, then we need a non-parametric method (e.g., Wilcox Test).
# Perform ANOVA
anova_result_shannon <- aov(alphaDiv ~ Species * GDD_5C, data = asv_scaled_noPlants_Phen_filt_LMM)
# Summarize the ANOVA results
summary(anova_result_shannon)
## Df Sum Sq Mean Sq F value Pr(>F)
## Species 1 14.551 14.551 32.731 2.69e-07 ***
## GDD_5C 1 0.016 0.016 0.037 0.848
## Species:GDD_5C 1 0.000 0.000 0.001 0.981
## Residuals 67 29.786 0.445
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Tukey HSD Post-Hoc Test:
# Perform Tukey HSD test
tukey_result_species <- TukeyHSD(aov(alphaDiv ~ Species, data = asv_scaled_noPlants_Phen_filt_LMM))
# Print the Tukey HSD test result
print(tukey_result_species)
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = alphaDiv ~ Species, data = asv_scaled_noPlants_Phen_filt_LMM)
##
## $Species
## diff lwr upr p adj
## Populus_tremuloides-Betula_populifolia 0.9055055 0.5942781 1.216733 2e-07
# install.packages('MuMIn')
library(MuMIn)
# Calculate marginal R-squared
shannon_marginal_r_squared <- r.squaredGLMM(lmm_model_shannon2, mu0 = "fixed")
print(shannon_marginal_r_squared)
## R2m R2c
## [1,] 0.2559408 0.331875
# install.packages('urca')
library(urca)
# Perform KPSS test
kpss_alphaDiv <- ur.kpss(asv_scaled_noPlants_Phen_filt_LMM$alphaDiv)
# summary of KPSS Test
summary(kpss_alphaDiv)
##
## #######################
## # KPSS Unit Root Test #
## #######################
##
## Test is of type: mu with 3 lags.
##
## Value of test-statistic is: 0.1623
##
## Critical value for a significance level of:
## 10pct 5pct 2.5pct 1pct
## critical values 0.347 0.463 0.574 0.739
# Shannon Diversity BEWTEEN SPECIES over GDDs is STATIONARY!
New Method: Subset
asv_scaled_noPLants_Phen_filt_LMM by each
GDD_5C, so then we have a dataset for each
GDD_5C. - Then, for each, test Normality of
specnumber (ASV richness) and alphaDiv
(Shannon index) -> if normal, then do ANOVA; if non-normal, do
non-parametric method.
NOTE: BOTH the biostats professor AND Itumeleng are correct, & I misunderstood. The biostats prof assumed that I already chose to do LMMs, so since we’re testing Normality on a MODEL, we have to test Normality of residuals (i.e., shapiro.test(residuals(lmm_model))). M
ethod HASN’T chosen a model yet!! - It’s ok to test the Normality of a variable directly here, b/c we are doing that TO choose a model (i.e., either ANOVA or non-parametric), so we can do: shapiro.test(asv_437$specnumber)
In Other Words:
The confusion arises from the context in which normality tests are applied. Both your biostatistics professor and the advice provided here are correct, but they apply to different stages of the analysis process.
Testing Normality of Residuals in LMMs: When you have a Linear Mixed Model (LMM) and you want to assess whether the residuals of your model are normally distributed, it is appropriate to use shapiro.test(residuals(lmm_model)). This is because the residuals are the differences between the observed values and the values predicted by the model. Testing the normality of these residuals directly addresses the assumption of normality in the residuals, which is crucial for the validity of many statistical tests and model assumptions.
Testing Normality of Variables Before Modeling: Before you fit an LMM or any other model, you might want to test the normality of your variables to inform your choice of model. For example, if you’re considering using ANOVA, you might first test the normality of your variables with shapiro.test(asv_437\(Diversity) or shapiro.test(asv_437\)Species). This is because ANOVA assumes that the data are normally distributed. However, this is a preliminary check and does not replace the need to test the normality of residuals after modeling, especially in the context of LMMs.
Choosing Between Parametric and Non-parametric Methods: Based on the normality test results, you can decide whether to use parametric (e.g., ANOVA) or non-parametric methods. If the residuals are normally distributed, you can proceed with parametric tests. If not, non-parametric methods might be more appropriate. This decision is based on the normality of the residuals, not the variables themselves.
Diagnostic Checks for LMMs: When using LMMs, it’s important to perform diagnostic checks to ensure the model’s assumptions are met. This includes checking for linearity, homoscedasticity, and the independence of residuals. These checks are specific to LMMs and help ensure the model’s validity 2.
Steps:
# Subset data by GDD
alpha_437 <- subset(asv_scaled_noPlants_Phen_filt_LMM, GDD_5C == 437)
alpha_605 <- subset(asv_scaled_noPlants_Phen_filt_LMM, GDD_5C == 605)
alpha_1087 <- subset(asv_scaled_noPlants_Phen_filt_LMM, GDD_5C == 1087)
alpha_1606 <- subset(asv_scaled_noPlants_Phen_filt_LMM, GDD_5C == 1606)
alpha_1992 <- subset(asv_scaled_noPlants_Phen_filt_LMM, GDD_5C == 1992)
alpha_2140 <- subset(asv_scaled_noPlants_Phen_filt_LMM, GDD_5C == 2140)
alpha_2219 <- subset(asv_scaled_noPlants_Phen_filt_LMM, GDD_5C == 2219)
#(a) GDD 437
shapiro.test(alpha_437$specnumber)
##
## Shapiro-Wilk normality test
##
## data: alpha_437$specnumber
## W = 0.96409, p-value = 0.8313
# p = 0.8189 > 0.05 --> it is NORMAL, so do ANOVA
# Perform ANOVA
anova_specnumber_437 <- aov(specnumber ~ Species, data = alpha_437)
# Summarize the ANOVA results
summary(anova_specnumber_437)
## Df Sum Sq Mean Sq F value Pr(>F)
## Species 1 152.1 152.1 0.666 0.438
## Residuals 8 1828.0 228.5
# Check Normality of Residuals & other diagnostic stats (Levene Test, Q-Q
# plots, Residuals vs. Fitted)?
# Normality of Residuals:
shapiro.test(residuals(anova_specnumber_437)) #p=0.204>0.05 --> Normality good!
##
## Shapiro-Wilk normality test
##
## data: residuals(anova_specnumber_437)
## W = 0.89719, p-value = 0.204
# Levene's Test? Q-Q? Residuals vs Fitted?
THEREFORE: There is NO significant difference in the ASV richness between the two host tree species at GDD 437 (p=0.43)!
#(b) GDD 605
shapiro.test(alpha_605$specnumber)
##
## Shapiro-Wilk normality test
##
## data: alpha_605$specnumber
## W = 0.94506, p-value = 0.6105
# p = 0.6105 > 0.05 --> it is NORMAL, so do ANOVA
# Perform ANOVA
anova_specnumber_605 <- aov(specnumber ~ Species, data = alpha_605)
# Summarize the ANOVA results
summary(anova_specnumber_605)
## Df Sum Sq Mean Sq F value Pr(>F)
## Species 1 2560 2560.0 13.6 0.00615 **
## Residuals 8 1506 188.2
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Check Normality of Residuals & other diagnostic stats (Levene Test, Q-Q
# plots, Residuals vs. Fitted)?
# Normality of Residuals:
shapiro.test(residuals(anova_specnumber_605)) #p=0.0752>0.05 --> Normality good!
##
## Shapiro-Wilk normality test
##
## data: residuals(anova_specnumber_605)
## W = 0.85946, p-value = 0.0752
# Levene's Test? Q-Q? Residuals vs Fitted?
THEREFORE: There IS a significant difference between the two host species at GDD 605 (p=0.00615)!
#(c) GDD 1087
shapiro.test(alpha_1087$specnumber)
##
## Shapiro-Wilk normality test
##
## data: alpha_1087$specnumber
## W = 0.83685, p-value = 0.02871
# p = 0.02871 < 0.05 --> it is NOT NORMAL, so do non-parametric Kruskal-Wallis
kruskal.test(alpha_1087$specnumber ~ alpha_1087$Species)
##
## Kruskal-Wallis rank sum test
##
## data: alpha_1087$specnumber by alpha_1087$Species
## Kruskal-Wallis chi-squared = 2.7, df = 1, p-value = 0.1003
# NOTE: No need to test normality of model, b/c Kruskal-Wallis is specifically
# for non-normality and assumes such.
# Levene Test? Q-Q Plots? Residuals vs. Fitted
THEREFORE: There is NO significant difference in ASV richness between the two host species at GDD 1087 (p=0.1003)!
#(d) GDD 1606
shapiro.test(alpha_1606$specnumber)
##
## Shapiro-Wilk normality test
##
## data: alpha_1606$specnumber
## W = 0.81248, p-value = 0.02055
# p = 0.01982 < 0.05 --> it is NOT NORMAL, so do non-parametric Kruskal-Wallis
kruskal.test(alpha_1606$specnumber ~ alpha_1606$Species)
##
## Kruskal-Wallis rank sum test
##
## data: alpha_1606$specnumber by alpha_1606$Species
## Kruskal-Wallis chi-squared = 0.27607, df = 1, p-value = 0.5993
# NOTE: No need to test normality of model, b/c Kruskal-Wallis is specifically
# for non-normality and assumes such.
# Levene Test? Q-Q Plots? Residuals vs. Fitted
THEREFORE: There is NO significant difference in ASV richness between the two host species at GDD 1606 (p=0.6752)!
#(e) GDD 1992
shapiro.test(alpha_1992$specnumber)
##
## Shapiro-Wilk normality test
##
## data: alpha_1992$specnumber
## W = 0.83889, p-value = 0.04279
# p = 0.04133 < 0.05 --> it is NOT NORMAL, so do non-parametric Kruskal-Wallis
kruskal.test(alpha_1992$specnumber ~ alpha_1992$Species)
##
## Kruskal-Wallis rank sum test
##
## data: alpha_1992$specnumber by alpha_1992$Species
## Kruskal-Wallis chi-squared = 0.88364, df = 1, p-value = 0.3472
# NOTE: No need to test normality of model, b/c Kruskal-Wallis is specifically
# for non-normality and assumes such.
# Levene Test? Q-Q Plots? Residuals vs. Fitted
THEREFORE: There is NO significant difference in ASV richness between the two host species at GDD 1992 (p=0.3472)!
#(f) GDD 2140
shapiro.test(alpha_2140$specnumber)
##
## Shapiro-Wilk normality test
##
## data: alpha_2140$specnumber
## W = 0.95179, p-value = 0.6897
# p = 0.6897 > 0.05 --> it is NORMAL, so do ANOVA
# Perform ANOVA
anova_specnumber_2140 <- aov(specnumber ~ Species, data = alpha_2140)
# Summarize the ANOVA results
summary(anova_specnumber_2140)
## Df Sum Sq Mean Sq F value Pr(>F)
## Species 1 14 14.4 0.014 0.91
## Residuals 8 8370 1046.3
# Check Normality of Residuals & other diagnostic stats (Levene Test, Q-Q
# plots, Residuals vs. Fitted)?
# Normality of Residuals:
shapiro.test(residuals(anova_specnumber_2140)) #p=0.7048>0.05 --> Normality good!
##
## Shapiro-Wilk normality test
##
## data: residuals(anova_specnumber_2140)
## W = 0.95482, p-value = 0.7256
# Levene's Test? Q-Q? Residuals vs Fitted?
THEREFORE: There is NO significant difference in ASV richness between the two host species at GDD 2140 (p=0.91)!
#(g) GDD 2219
shapiro.test(alpha_2219$specnumber)
##
## Shapiro-Wilk normality test
##
## data: alpha_2219$specnumber
## W = 0.93047, p-value = 0.4525
# p = 0.469 > 0.05 --> it is NORMAL, so do ANOVA
# Perform ANOVA
anova_specnumber_2219 <- aov(specnumber ~ Species, data = alpha_2219)
# Summarize the ANOVA results
summary(anova_specnumber_2219)
## Df Sum Sq Mean Sq F value Pr(>F)
## Species 1 10 10.0 0.014 0.909
## Residuals 8 5686 710.8
# Check Normality of Residuals & other diagnostic stats (Levene Test, Q-Q
# plots, Residuals vs. Fitted)?
# Normality of Residuals:
shapiro.test(residuals(anova_specnumber_2219)) #p=0.4304>0.05 --> Normality good!
##
## Shapiro-Wilk normality test
##
## data: residuals(anova_specnumber_2219)
## W = 0.92583, p-value = 0.4081
# Levene's Test? Q-Q? Residuals vs Fitted?
THEREFORE: There is NO significant difference in ASV richness between the two host species at GDD 2219 (p=0.899)!
#(a) GDD 437
shapiro.test(alpha_437$alphaDiv)
##
## Shapiro-Wilk normality test
##
## data: alpha_437$alphaDiv
## W = 0.85701, p-value = 0.07036
# p = 0.07414 > 0.05 --> it is NORMAL, so do ANOVA
# Perform ANOVA
anova_shannon_437 <- aov(alphaDiv ~ Species, data = alpha_437)
# Summarize the ANOVA results
summary(anova_shannon_437)
## Df Sum Sq Mean Sq F value Pr(>F)
## Species 1 1.973 1.973 8.888 0.0176 *
## Residuals 8 1.776 0.222
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Formal Test of Normality of Residuals
shapiro.test(residuals(anova_shannon_437))
##
## Shapiro-Wilk normality test
##
## data: residuals(anova_shannon_437)
## W = 0.85276, p-value = 0.06265
# p=0.06265 which is technically >0.05, so residuals NOT normal... However,
# it's so close to 0.05, and since `alphaDiv` response variable is normally
# distributed, we can likely rely on ANOVA results.
THEREFORE: There IS a significant difference in Shannon diversity between the two host species at GDD 437 (p=0.0165)!
#(b) GDD 605
shapiro.test(alpha_605$alphaDiv)
##
## Shapiro-Wilk normality test
##
## data: alpha_605$alphaDiv
## W = 0.94582, p-value = 0.6194
# p = 0.6194 > 0.05 --> it is NORMAL, so do ANOVA
# Perform ANOVA
anova_shannon_605 <- aov(alphaDiv ~ Species, data = alpha_605)
# Summarize the ANOVA results
summary(anova_shannon_605)
## Df Sum Sq Mean Sq F value Pr(>F)
## Species 1 3.789 3.789 19.57 0.00222 **
## Residuals 8 1.549 0.194
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Normality of Residuals:
shapiro.test(residuals(anova_shannon_605)) #p=0.3227 > 0.05 --> it's Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(anova_shannon_605)
## W = 0.91573, p-value = 0.3227
# Levene Test? Q-Q Plots? Residuals vs. Fitted
THEREFORE: There IS significant difference in Shannon diversity between the two host species at GDD 605 (p=0.00222)!
#(c) GDD 1087
shapiro.test(alpha_1087$alphaDiv)
##
## Shapiro-Wilk normality test
##
## data: alpha_1087$alphaDiv
## W = 0.94934, p-value = 0.6356
# p = 0.6356 > 0.05 --> it is NORMAL, so do ANOVA
# Perform ANOVA
anova_shannon_1087 <- aov(alphaDiv ~ Species, data = alpha_1087)
# Summarize the ANOVA results
summary(anova_shannon_1087)
## Df Sum Sq Mean Sq F value Pr(>F)
## Species 1 1.885 1.8848 3.345 0.101
## Residuals 9 5.072 0.5635
# Normality of Residuals:
shapiro.test(residuals(anova_shannon_1087)) #p=0.7229 > 0.05 --> it's Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(anova_shannon_1087)
## W = 0.95615, p-value = 0.7229
# Levene Test? Q-Q Plots? Residuals vs. Fitted
THEREFORE: There is NO significant difference in Shannon diversity between the two host species at GDD 1087 (p=0.101)!
#(d) GDD 1606
shapiro.test(alpha_1606$alphaDiv)
##
## Shapiro-Wilk normality test
##
## data: alpha_1606$alphaDiv
## W = 0.93135, p-value = 0.4613
# p = 0.4786 > 0.05 --> it is NORMAL, so do ANOVA
# Perform ANOVA
anova_shannon_1606 <- aov(alphaDiv ~ Species, data = alpha_1606)
# Summarize the ANOVA results
summary(anova_shannon_1606)
## Df Sum Sq Mean Sq F value Pr(>F)
## Species 1 0.243 0.2429 0.192 0.673
## Residuals 8 10.098 1.2623
# Normality of Residuals:
shapiro.test(residuals(anova_shannon_1606)) #p=0.3012 > 0.05 --> it's Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(anova_shannon_1606)
## W = 0.91143, p-value = 0.291
# Levene Test? Q-Q Plots? Residuals vs. Fitted
THEREFORE: There is NO significant difference in Shannon diversity between the two host species at GDD 1606 (p=0.665)!
#(e) GDD 1992
shapiro.test(alpha_1992$alphaDiv)
##
## Shapiro-Wilk normality test
##
## data: alpha_1992$alphaDiv
## W = 0.91643, p-value = 0.3282
# p = 0.3228 > 0.05 --> it is NORMAL, so do ANOVA
# Perform ANOVA
anova_shannon_1992 <- aov(alphaDiv ~ Species, data = alpha_1992)
# Summarize the ANOVA results
summary(anova_shannon_1992)
## Df Sum Sq Mean Sq F value Pr(>F)
## Species 1 0.6777 0.6777 2.099 0.185
## Residuals 8 2.5833 0.3229
# Normality of Residuals:
shapiro.test(residuals(anova_shannon_1992)) #p=0.3006 > 0.05 --> it's Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(anova_shannon_1992)
## W = 0.91329, p-value = 0.3044
# Levene Test? Q-Q Plots? Residuals vs. Fitted
THEREFORE: There is NO significant difference in Shannon diversity between the two host species at GDD 1992 (p=0.185)!
#(f) GDD 2140
shapiro.test(alpha_2140$alphaDiv)
##
## Shapiro-Wilk normality test
##
## data: alpha_2140$alphaDiv
## W = 0.89396, p-value = 0.1878
# p = 0.2041 > 0.05 --> it is NORMAL, so do ANOVA
# Perform ANOVA
anova_shannon_2140 <- aov(alphaDiv ~ Species, data = alpha_2140)
# Summarize the ANOVA results
summary(anova_shannon_2140)
## Df Sum Sq Mean Sq F value Pr(>F)
## Species 1 4.460 4.460 14.15 0.00553 **
## Residuals 8 2.521 0.315
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Normality of Residuals:
shapiro.test(residuals(anova_shannon_2140)) #p=0.08083 > 0.05 --> it's Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(anova_shannon_2140)
## W = 0.85525, p-value = 0.06706
# Levene Test? Q-Q Plots? Residuals vs. Fitted
THEREFORE: There IS a significant difference in Shannon diversity between the two host species at GDD 2140 (p=0.00553)!
#(g) GDD 2219
shapiro.test(alpha_2219$alphaDiv)
##
## Shapiro-Wilk normality test
##
## data: alpha_2219$alphaDiv
## W = 0.96005, p-value = 0.7864
# p = 0.79 > 0.05 --> it is NORMAL, so do ANOVA
# Perform ANOVA
anova_shannon_2219 <- aov(alphaDiv ~ Species, data = alpha_2219)
# Summarize the ANOVA results
summary(anova_shannon_2219)
## Df Sum Sq Mean Sq F value Pr(>F)
## Species 1 3.584 3.584 12.59 0.00752 **
## Residuals 8 2.277 0.285
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Normality of Residuals:
shapiro.test(residuals(anova_shannon_2219)) #p=0.436 > 0.05 --> it's Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(anova_shannon_2219)
## W = 0.92788, p-value = 0.4273
# Levene Test? Q-Q Plots? Residuals vs. Fitted
THEREFORE: There IS a significant difference in Shannon diversity between the two host species at GDD 2219 (p=0.00752)!
NOTE: We do BOTH the separate ANOVAs & the LMMs!! Here’s why:
2-Step Approach:
Our approach is correct and aligns well with the goals of our analysis. Here’s a summary of your plan:
Analyzing Species-Driven Differences at Each GDD: By using ANOVA or Kruskal-Wallis models for each subset of your data corresponding to the 7 GDD sampling points, you’re effectively examining how the identity of the host Species impacts bacterial diversity (Diversity) at each GDD level. This method allows you to identify where species exert the most effect on diversity across different GDD levels.
Assessing the Overall Impact of Species, GDD, and Their Interaction on Diversity: By incorporating GDD as a continuous variable and its interaction with Species into a Linear Mixed Model (LMM), you’re addressing the broader question of how GDD affects Diversity across all species and whether this effect varies by species. The equation Diversity ~ Species + GDD + Species:GDD in your LMM will help you understand the main effects of Species and GDD on Diversity, as well as the interaction between Species and GDD.
This two-step approach is appropriate for our analysis. The first step provides insights into species-driven differences at each GDD level, while the second step offers a comprehensive view of the overall impact of GDD and its interaction with Species on Diversity. This combination of analyses allows you to explore both the specific effects of species at different GDD levels and the broader effects of GDD and its interaction with Species on bacterial diversity.
emmeans# Create a column `GDD_5C_bins` to bin (categorize) continuous GDDs
sampling_points <- c(437, 605, 1087, 1606, 1992, 2140, 2219)
asv_scaled_noPlants_Phen_filt_LMM$GDD_5C_bins <- cut(asv_scaled_noPlants_Phen_filt_LMM$GDD_5C,
breaks = c(-Inf, sampling_points, Inf), labels = c("437", "605", "1087", "1606",
"1992", "2140", "2219", "2220+"), include.lowest = TRUE)
library(emmeans)
## Welcome to emmeans.
## Caution: You lose important information if you filter this package's results.
## See '? untidy'
##
## Attaching package: 'emmeans'
## The following object is masked from 'package:HH':
##
## as.glht
## The following object is masked from 'package:GGally':
##
## pigs
## The following object is masked from 'package:devtools':
##
## test
# ASV RICHNESS PAIRWISE COMPARISONS
# (EMMEANS):#######################################################
# Define the GDD levels of interest
gdd_levels <- c(437, 605, 1087, 1606, 1992, 2140, 2219)
# Run emmeans with specified GDD levels
emm_specnumber_interspecific <- emmeans(lmm_model_specnumber3, specs = pairwise ~
Species:GDD_5C, at = list(GDD_5C = gdd_levels))
emm_specnumber_interspecific$emmeans
## Species GDD_5C emmean SE df lower.CL upper.CL
## Betula_populifolia 437 3.20 0.183 25.57 2.83 3.58
## Populus_tremuloides 437 3.84 0.181 24.81 3.47 4.21
## Betula_populifolia 605 3.28 0.169 19.77 2.93 3.63
## Populus_tremuloides 605 3.83 0.168 19.13 3.48 4.19
## Betula_populifolia 1087 3.50 0.141 9.91 3.19 3.82
## Populus_tremuloides 1087 3.82 0.140 9.60 3.50 4.13
## Betula_populifolia 1606 3.75 0.135 8.47 3.44 4.06
## Populus_tremuloides 1606 3.80 0.135 8.33 3.49 4.11
## Betula_populifolia 1992 3.93 0.150 12.75 3.60 4.25
## Populus_tremuloides 1992 3.78 0.150 12.68 3.46 4.11
## Betula_populifolia 2140 4.00 0.159 15.94 3.66 4.33
## Populus_tremuloides 2140 3.78 0.159 15.89 3.44 4.11
## Betula_populifolia 2219 4.03 0.165 18.05 3.69 4.38
## Populus_tremuloides 2219 3.77 0.165 18.01 3.43 4.12
##
## Degrees-of-freedom method: kenward-roger
## Results are given on the log (not the response) scale.
## Confidence level used: 0.95
summary(emm_specnumber_interspecific$contrasts)
## contrast estimate
## Betula_populifolia GDD_5C437 - Populus_tremuloides GDD_5C437 -0.63993
## Betula_populifolia GDD_5C437 - Betula_populifolia GDD_5C605 -0.07853
## Betula_populifolia GDD_5C437 - Populus_tremuloides GDD_5C605 -0.63357
## Betula_populifolia GDD_5C437 - Betula_populifolia GDD_5C1087 -0.30383
## Betula_populifolia GDD_5C437 - Populus_tremuloides GDD_5C1087 -0.61534
## Betula_populifolia GDD_5C437 - Betula_populifolia GDD_5C1606 -0.54642
## Betula_populifolia GDD_5C437 - Populus_tremuloides GDD_5C1606 -0.59571
## Betula_populifolia GDD_5C437 - Betula_populifolia GDD_5C1992 -0.72685
## Betula_populifolia GDD_5C437 - Populus_tremuloides GDD_5C1992 -0.58111
## Betula_populifolia GDD_5C437 - Betula_populifolia GDD_5C2140 -0.79603
## Betula_populifolia GDD_5C437 - Populus_tremuloides GDD_5C2140 -0.57551
## Betula_populifolia GDD_5C437 - Betula_populifolia GDD_5C2219 -0.83296
## Betula_populifolia GDD_5C437 - Populus_tremuloides GDD_5C2219 -0.57252
## Populus_tremuloides GDD_5C437 - Betula_populifolia GDD_5C605 0.56140
## Populus_tremuloides GDD_5C437 - Populus_tremuloides GDD_5C605 0.00635
## Populus_tremuloides GDD_5C437 - Betula_populifolia GDD_5C1087 0.33610
## Populus_tremuloides GDD_5C437 - Populus_tremuloides GDD_5C1087 0.02459
## Populus_tremuloides GDD_5C437 - Betula_populifolia GDD_5C1606 0.09351
## Populus_tremuloides GDD_5C437 - Populus_tremuloides GDD_5C1606 0.04422
## Populus_tremuloides GDD_5C437 - Betula_populifolia GDD_5C1992 -0.08692
## Populus_tremuloides GDD_5C437 - Populus_tremuloides GDD_5C1992 0.05882
## Populus_tremuloides GDD_5C437 - Betula_populifolia GDD_5C2140 -0.15610
## Populus_tremuloides GDD_5C437 - Populus_tremuloides GDD_5C2140 0.06441
## Populus_tremuloides GDD_5C437 - Betula_populifolia GDD_5C2219 -0.19303
## Populus_tremuloides GDD_5C437 - Populus_tremuloides GDD_5C2219 0.06740
## Betula_populifolia GDD_5C605 - Populus_tremuloides GDD_5C605 -0.55505
## Betula_populifolia GDD_5C605 - Betula_populifolia GDD_5C1087 -0.22530
## Betula_populifolia GDD_5C605 - Populus_tremuloides GDD_5C1087 -0.53681
## Betula_populifolia GDD_5C605 - Betula_populifolia GDD_5C1606 -0.46789
## Betula_populifolia GDD_5C605 - Populus_tremuloides GDD_5C1606 -0.51718
## Betula_populifolia GDD_5C605 - Betula_populifolia GDD_5C1992 -0.64832
## Betula_populifolia GDD_5C605 - Populus_tremuloides GDD_5C1992 -0.50258
## Betula_populifolia GDD_5C605 - Betula_populifolia GDD_5C2140 -0.71750
## Betula_populifolia GDD_5C605 - Populus_tremuloides GDD_5C2140 -0.49699
## Betula_populifolia GDD_5C605 - Betula_populifolia GDD_5C2219 -0.75443
## Betula_populifolia GDD_5C605 - Populus_tremuloides GDD_5C2219 -0.49400
## Populus_tremuloides GDD_5C605 - Betula_populifolia GDD_5C1087 0.32975
## Populus_tremuloides GDD_5C605 - Populus_tremuloides GDD_5C1087 0.01823
## Populus_tremuloides GDD_5C605 - Betula_populifolia GDD_5C1606 0.08715
## Populus_tremuloides GDD_5C605 - Populus_tremuloides GDD_5C1606 0.03786
## Populus_tremuloides GDD_5C605 - Betula_populifolia GDD_5C1992 -0.09328
## Populus_tremuloides GDD_5C605 - Populus_tremuloides GDD_5C1992 0.05246
## Populus_tremuloides GDD_5C605 - Betula_populifolia GDD_5C2140 -0.16246
## Populus_tremuloides GDD_5C605 - Populus_tremuloides GDD_5C2140 0.05806
## Populus_tremuloides GDD_5C605 - Betula_populifolia GDD_5C2219 -0.19938
## Populus_tremuloides GDD_5C605 - Populus_tremuloides GDD_5C2219 0.06105
## Betula_populifolia GDD_5C1087 - Populus_tremuloides GDD_5C1087 -0.31151
## Betula_populifolia GDD_5C1087 - Betula_populifolia GDD_5C1606 -0.24259
## Betula_populifolia GDD_5C1087 - Populus_tremuloides GDD_5C1606 -0.29188
## Betula_populifolia GDD_5C1087 - Betula_populifolia GDD_5C1992 -0.42302
## Betula_populifolia GDD_5C1087 - Populus_tremuloides GDD_5C1992 -0.27728
## Betula_populifolia GDD_5C1087 - Betula_populifolia GDD_5C2140 -0.49220
## Betula_populifolia GDD_5C1087 - Populus_tremuloides GDD_5C2140 -0.27169
## Betula_populifolia GDD_5C1087 - Betula_populifolia GDD_5C2219 -0.52913
## Betula_populifolia GDD_5C1087 - Populus_tremuloides GDD_5C2219 -0.26870
## Populus_tremuloides GDD_5C1087 - Betula_populifolia GDD_5C1606 0.06892
## Populus_tremuloides GDD_5C1087 - Populus_tremuloides GDD_5C1606 0.01963
## Populus_tremuloides GDD_5C1087 - Betula_populifolia GDD_5C1992 -0.11151
## Populus_tremuloides GDD_5C1087 - Populus_tremuloides GDD_5C1992 0.03423
## Populus_tremuloides GDD_5C1087 - Betula_populifolia GDD_5C2140 -0.18069
## Populus_tremuloides GDD_5C1087 - Populus_tremuloides GDD_5C2140 0.03983
## Populus_tremuloides GDD_5C1087 - Betula_populifolia GDD_5C2219 -0.21761
## Populus_tremuloides GDD_5C1087 - Populus_tremuloides GDD_5C2219 0.04282
## Betula_populifolia GDD_5C1606 - Populus_tremuloides GDD_5C1606 -0.04929
## Betula_populifolia GDD_5C1606 - Betula_populifolia GDD_5C1992 -0.18043
## Betula_populifolia GDD_5C1606 - Populus_tremuloides GDD_5C1992 -0.03469
## Betula_populifolia GDD_5C1606 - Betula_populifolia GDD_5C2140 -0.24961
## Betula_populifolia GDD_5C1606 - Populus_tremuloides GDD_5C2140 -0.02909
## Betula_populifolia GDD_5C1606 - Betula_populifolia GDD_5C2219 -0.28653
## Betula_populifolia GDD_5C1606 - Populus_tremuloides GDD_5C2219 -0.02610
## Populus_tremuloides GDD_5C1606 - Betula_populifolia GDD_5C1992 -0.13114
## Populus_tremuloides GDD_5C1606 - Populus_tremuloides GDD_5C1992 0.01460
## Populus_tremuloides GDD_5C1606 - Betula_populifolia GDD_5C2140 -0.20032
## Populus_tremuloides GDD_5C1606 - Populus_tremuloides GDD_5C2140 0.02020
## Populus_tremuloides GDD_5C1606 - Betula_populifolia GDD_5C2219 -0.23724
## Populus_tremuloides GDD_5C1606 - Populus_tremuloides GDD_5C2219 0.02319
## Betula_populifolia GDD_5C1992 - Populus_tremuloides GDD_5C1992 0.14574
## Betula_populifolia GDD_5C1992 - Betula_populifolia GDD_5C2140 -0.06918
## Betula_populifolia GDD_5C1992 - Populus_tremuloides GDD_5C2140 0.15134
## Betula_populifolia GDD_5C1992 - Betula_populifolia GDD_5C2219 -0.10611
## Betula_populifolia GDD_5C1992 - Populus_tremuloides GDD_5C2219 0.15432
## Populus_tremuloides GDD_5C1992 - Betula_populifolia GDD_5C2140 -0.21492
## Populus_tremuloides GDD_5C1992 - Populus_tremuloides GDD_5C2140 0.00560
## Populus_tremuloides GDD_5C1992 - Betula_populifolia GDD_5C2219 -0.25184
## Populus_tremuloides GDD_5C1992 - Populus_tremuloides GDD_5C2219 0.00859
## Betula_populifolia GDD_5C2140 - Populus_tremuloides GDD_5C2140 0.22052
## Betula_populifolia GDD_5C2140 - Betula_populifolia GDD_5C2219 -0.03693
## Betula_populifolia GDD_5C2140 - Populus_tremuloides GDD_5C2219 0.22350
## Populus_tremuloides GDD_5C2140 - Betula_populifolia GDD_5C2219 -0.25744
## Populus_tremuloides GDD_5C2140 - Populus_tremuloides GDD_5C2219 0.00299
## Betula_populifolia GDD_5C2219 - Populus_tremuloides GDD_5C2219 0.26043
## SE df t.ratio p.value
## 0.25700 25.19 -2.487 0.4524
## 0.02080 59.00 -3.766 0.0236
## 0.24800 22.33 -2.555 0.4172
## 0.08070 59.00 -3.766 0.0236
## 0.23000 17.15 -2.676 0.3647
## 0.14500 59.00 -3.766 0.0236
## 0.22700 16.37 -2.625 0.3932
## 0.19300 59.00 -3.766 0.0236
## 0.23600 18.93 -2.459 0.4779
## 0.21100 59.00 -3.766 0.0236
## 0.24200 20.66 -2.375 0.5255
## 0.22100 59.00 -3.766 0.0236
## 0.24600 21.76 -2.327 0.5539
## 0.24800 22.28 2.265 0.5923
## 0.02080 59.04 0.306 1.0000
## 0.22900 16.98 1.466 0.9571
## 0.08040 59.04 0.306 1.0000
## 0.22600 16.10 0.414 1.0000
## 0.14500 59.04 0.306 1.0000
## 0.23500 18.60 -0.369 1.0000
## 0.19200 59.04 0.306 1.0000
## 0.24100 20.32 -0.647 1.0000
## 0.21100 59.04 0.306 1.0000
## 0.24500 21.41 -0.788 0.9999
## 0.22000 59.04 0.306 1.0000
## 0.23800 19.45 -2.330 0.5541
## 0.05980 59.00 -3.766 0.0236
## 0.21900 14.41 -2.448 0.4936
## 0.12400 59.00 -3.766 0.0236
## 0.21600 13.67 -2.392 0.5262
## 0.17200 59.00 -3.766 0.0236
## 0.22600 16.12 -2.224 0.6204
## 0.19000 59.00 -3.766 0.0236
## 0.23200 17.81 -2.140 0.6699
## 0.20000 59.00 -3.766 0.0236
## 0.23600 18.88 -2.092 0.6982
## 0.21900 14.30 1.506 0.9452
## 0.05960 59.04 0.306 1.0000
## 0.21500 13.46 0.405 1.0000
## 0.12400 59.04 0.306 1.0000
## 0.22500 15.86 -0.414 1.0000
## 0.17200 59.04 0.306 1.0000
## 0.23100 17.52 -0.702 1.0000
## 0.19000 59.04 0.306 1.0000
## 0.23500 18.59 -0.848 0.9997
## 0.20000 59.04 0.306 1.0000
## 0.19800 9.76 -1.572 0.9189
## 0.06440 59.00 -3.766 0.0236
## 0.19500 9.11 -1.499 0.9371
## 0.11200 59.00 -3.766 0.0236
## 0.20600 11.26 -1.349 0.9714
## 0.13100 59.00 -3.766 0.0236
## 0.21200 12.78 -1.279 0.9820
## 0.14000 59.00 -3.766 0.0236
## 0.21700 13.77 -1.240 0.9864
## 0.19400 9.03 0.355 1.0000
## 0.06420 59.04 0.306 1.0000
## 0.20500 11.14 -0.544 1.0000
## 0.11200 59.04 0.306 1.0000
## 0.21200 12.64 -0.853 0.9995
## 0.13000 59.04 0.306 1.0000
## 0.21600 13.62 -1.007 0.9977
## 0.14000 59.04 0.306 1.0000
## 0.19100 8.40 -0.258 1.0000
## 0.04790 59.00 -3.766 0.0236
## 0.20200 10.49 -0.172 1.0000
## 0.06630 59.00 -3.766 0.0236
## 0.20900 11.98 -0.139 1.0000
## 0.07610 59.00 -3.766 0.0236
## 0.21300 12.95 -0.122 1.0000
## 0.20200 10.45 -0.650 1.0000
## 0.04770 59.04 0.306 1.0000
## 0.20900 11.92 -0.960 0.9984
## 0.06600 59.04 0.306 1.0000
## 0.21300 12.88 -1.115 0.9941
## 0.07580 59.04 0.306 1.0000
## 0.21200 12.72 0.687 1.0000
## 0.01840 59.00 -3.766 0.0236
## 0.21900 14.30 0.692 1.0000
## 0.02820 59.00 -3.766 0.0236
## 0.22300 15.32 0.692 1.0000
## 0.21900 14.28 -0.982 0.9983
## 0.01830 59.04 0.306 1.0000
## 0.22300 15.30 -1.130 0.9941
## 0.02810 59.04 0.306 1.0000
## 0.22500 15.92 0.979 0.9985
## 0.00980 59.00 -3.766 0.0236
## 0.22900 16.97 0.975 0.9986
## 0.22900 16.96 -1.123 0.9948
## 0.00977 59.04 0.306 1.0000
## 0.23300 18.03 1.117 0.9952
##
## Degrees-of-freedom method: kenward-roger
## Results are given on the log (not the response) scale.
## P value adjustment: tukey method for comparing a family of 14 estimates
#####################################
# Perform pairwise comparisons
pairwise_comparisons <- pairs(emm_specnumber_interspecific)
# View results
summary(pairwise_comparisons)
## contrast estimate
## Betula_populifolia GDD_5C437 - Populus_tremuloides GDD_5C437 -0.63993
## Betula_populifolia GDD_5C437 - Betula_populifolia GDD_5C605 -0.07853
## Betula_populifolia GDD_5C437 - Populus_tremuloides GDD_5C605 -0.63357
## Betula_populifolia GDD_5C437 - Betula_populifolia GDD_5C1087 -0.30383
## Betula_populifolia GDD_5C437 - Populus_tremuloides GDD_5C1087 -0.61534
## Betula_populifolia GDD_5C437 - Betula_populifolia GDD_5C1606 -0.54642
## Betula_populifolia GDD_5C437 - Populus_tremuloides GDD_5C1606 -0.59571
## Betula_populifolia GDD_5C437 - Betula_populifolia GDD_5C1992 -0.72685
## Betula_populifolia GDD_5C437 - Populus_tremuloides GDD_5C1992 -0.58111
## Betula_populifolia GDD_5C437 - Betula_populifolia GDD_5C2140 -0.79603
## Betula_populifolia GDD_5C437 - Populus_tremuloides GDD_5C2140 -0.57551
## Betula_populifolia GDD_5C437 - Betula_populifolia GDD_5C2219 -0.83296
## Betula_populifolia GDD_5C437 - Populus_tremuloides GDD_5C2219 -0.57252
## Populus_tremuloides GDD_5C437 - Betula_populifolia GDD_5C605 0.56140
## Populus_tremuloides GDD_5C437 - Populus_tremuloides GDD_5C605 0.00635
## Populus_tremuloides GDD_5C437 - Betula_populifolia GDD_5C1087 0.33610
## Populus_tremuloides GDD_5C437 - Populus_tremuloides GDD_5C1087 0.02459
## Populus_tremuloides GDD_5C437 - Betula_populifolia GDD_5C1606 0.09351
## Populus_tremuloides GDD_5C437 - Populus_tremuloides GDD_5C1606 0.04422
## Populus_tremuloides GDD_5C437 - Betula_populifolia GDD_5C1992 -0.08692
## Populus_tremuloides GDD_5C437 - Populus_tremuloides GDD_5C1992 0.05882
## Populus_tremuloides GDD_5C437 - Betula_populifolia GDD_5C2140 -0.15610
## Populus_tremuloides GDD_5C437 - Populus_tremuloides GDD_5C2140 0.06441
## Populus_tremuloides GDD_5C437 - Betula_populifolia GDD_5C2219 -0.19303
## Populus_tremuloides GDD_5C437 - Populus_tremuloides GDD_5C2219 0.06740
## Betula_populifolia GDD_5C605 - Populus_tremuloides GDD_5C605 -0.55505
## Betula_populifolia GDD_5C605 - Betula_populifolia GDD_5C1087 -0.22530
## Betula_populifolia GDD_5C605 - Populus_tremuloides GDD_5C1087 -0.53681
## Betula_populifolia GDD_5C605 - Betula_populifolia GDD_5C1606 -0.46789
## Betula_populifolia GDD_5C605 - Populus_tremuloides GDD_5C1606 -0.51718
## Betula_populifolia GDD_5C605 - Betula_populifolia GDD_5C1992 -0.64832
## Betula_populifolia GDD_5C605 - Populus_tremuloides GDD_5C1992 -0.50258
## Betula_populifolia GDD_5C605 - Betula_populifolia GDD_5C2140 -0.71750
## Betula_populifolia GDD_5C605 - Populus_tremuloides GDD_5C2140 -0.49699
## Betula_populifolia GDD_5C605 - Betula_populifolia GDD_5C2219 -0.75443
## Betula_populifolia GDD_5C605 - Populus_tremuloides GDD_5C2219 -0.49400
## Populus_tremuloides GDD_5C605 - Betula_populifolia GDD_5C1087 0.32975
## Populus_tremuloides GDD_5C605 - Populus_tremuloides GDD_5C1087 0.01823
## Populus_tremuloides GDD_5C605 - Betula_populifolia GDD_5C1606 0.08715
## Populus_tremuloides GDD_5C605 - Populus_tremuloides GDD_5C1606 0.03786
## Populus_tremuloides GDD_5C605 - Betula_populifolia GDD_5C1992 -0.09328
## Populus_tremuloides GDD_5C605 - Populus_tremuloides GDD_5C1992 0.05246
## Populus_tremuloides GDD_5C605 - Betula_populifolia GDD_5C2140 -0.16246
## Populus_tremuloides GDD_5C605 - Populus_tremuloides GDD_5C2140 0.05806
## Populus_tremuloides GDD_5C605 - Betula_populifolia GDD_5C2219 -0.19938
## Populus_tremuloides GDD_5C605 - Populus_tremuloides GDD_5C2219 0.06105
## Betula_populifolia GDD_5C1087 - Populus_tremuloides GDD_5C1087 -0.31151
## Betula_populifolia GDD_5C1087 - Betula_populifolia GDD_5C1606 -0.24259
## Betula_populifolia GDD_5C1087 - Populus_tremuloides GDD_5C1606 -0.29188
## Betula_populifolia GDD_5C1087 - Betula_populifolia GDD_5C1992 -0.42302
## Betula_populifolia GDD_5C1087 - Populus_tremuloides GDD_5C1992 -0.27728
## Betula_populifolia GDD_5C1087 - Betula_populifolia GDD_5C2140 -0.49220
## Betula_populifolia GDD_5C1087 - Populus_tremuloides GDD_5C2140 -0.27169
## Betula_populifolia GDD_5C1087 - Betula_populifolia GDD_5C2219 -0.52913
## Betula_populifolia GDD_5C1087 - Populus_tremuloides GDD_5C2219 -0.26870
## Populus_tremuloides GDD_5C1087 - Betula_populifolia GDD_5C1606 0.06892
## Populus_tremuloides GDD_5C1087 - Populus_tremuloides GDD_5C1606 0.01963
## Populus_tremuloides GDD_5C1087 - Betula_populifolia GDD_5C1992 -0.11151
## Populus_tremuloides GDD_5C1087 - Populus_tremuloides GDD_5C1992 0.03423
## Populus_tremuloides GDD_5C1087 - Betula_populifolia GDD_5C2140 -0.18069
## Populus_tremuloides GDD_5C1087 - Populus_tremuloides GDD_5C2140 0.03983
## Populus_tremuloides GDD_5C1087 - Betula_populifolia GDD_5C2219 -0.21761
## Populus_tremuloides GDD_5C1087 - Populus_tremuloides GDD_5C2219 0.04282
## Betula_populifolia GDD_5C1606 - Populus_tremuloides GDD_5C1606 -0.04929
## Betula_populifolia GDD_5C1606 - Betula_populifolia GDD_5C1992 -0.18043
## Betula_populifolia GDD_5C1606 - Populus_tremuloides GDD_5C1992 -0.03469
## Betula_populifolia GDD_5C1606 - Betula_populifolia GDD_5C2140 -0.24961
## Betula_populifolia GDD_5C1606 - Populus_tremuloides GDD_5C2140 -0.02909
## Betula_populifolia GDD_5C1606 - Betula_populifolia GDD_5C2219 -0.28653
## Betula_populifolia GDD_5C1606 - Populus_tremuloides GDD_5C2219 -0.02610
## Populus_tremuloides GDD_5C1606 - Betula_populifolia GDD_5C1992 -0.13114
## Populus_tremuloides GDD_5C1606 - Populus_tremuloides GDD_5C1992 0.01460
## Populus_tremuloides GDD_5C1606 - Betula_populifolia GDD_5C2140 -0.20032
## Populus_tremuloides GDD_5C1606 - Populus_tremuloides GDD_5C2140 0.02020
## Populus_tremuloides GDD_5C1606 - Betula_populifolia GDD_5C2219 -0.23724
## Populus_tremuloides GDD_5C1606 - Populus_tremuloides GDD_5C2219 0.02319
## Betula_populifolia GDD_5C1992 - Populus_tremuloides GDD_5C1992 0.14574
## Betula_populifolia GDD_5C1992 - Betula_populifolia GDD_5C2140 -0.06918
## Betula_populifolia GDD_5C1992 - Populus_tremuloides GDD_5C2140 0.15134
## Betula_populifolia GDD_5C1992 - Betula_populifolia GDD_5C2219 -0.10611
## Betula_populifolia GDD_5C1992 - Populus_tremuloides GDD_5C2219 0.15432
## Populus_tremuloides GDD_5C1992 - Betula_populifolia GDD_5C2140 -0.21492
## Populus_tremuloides GDD_5C1992 - Populus_tremuloides GDD_5C2140 0.00560
## Populus_tremuloides GDD_5C1992 - Betula_populifolia GDD_5C2219 -0.25184
## Populus_tremuloides GDD_5C1992 - Populus_tremuloides GDD_5C2219 0.00859
## Betula_populifolia GDD_5C2140 - Populus_tremuloides GDD_5C2140 0.22052
## Betula_populifolia GDD_5C2140 - Betula_populifolia GDD_5C2219 -0.03693
## Betula_populifolia GDD_5C2140 - Populus_tremuloides GDD_5C2219 0.22350
## Populus_tremuloides GDD_5C2140 - Betula_populifolia GDD_5C2219 -0.25744
## Populus_tremuloides GDD_5C2140 - Populus_tremuloides GDD_5C2219 0.00299
## Betula_populifolia GDD_5C2219 - Populus_tremuloides GDD_5C2219 0.26043
## SE df t.ratio p.value
## 0.25700 25.19 -2.487 0.4524
## 0.02080 59.00 -3.766 0.0236
## 0.24800 22.33 -2.555 0.4172
## 0.08070 59.00 -3.766 0.0236
## 0.23000 17.15 -2.676 0.3647
## 0.14500 59.00 -3.766 0.0236
## 0.22700 16.37 -2.625 0.3932
## 0.19300 59.00 -3.766 0.0236
## 0.23600 18.93 -2.459 0.4779
## 0.21100 59.00 -3.766 0.0236
## 0.24200 20.66 -2.375 0.5255
## 0.22100 59.00 -3.766 0.0236
## 0.24600 21.76 -2.327 0.5539
## 0.24800 22.28 2.265 0.5923
## 0.02080 59.04 0.306 1.0000
## 0.22900 16.98 1.466 0.9571
## 0.08040 59.04 0.306 1.0000
## 0.22600 16.10 0.414 1.0000
## 0.14500 59.04 0.306 1.0000
## 0.23500 18.60 -0.369 1.0000
## 0.19200 59.04 0.306 1.0000
## 0.24100 20.32 -0.647 1.0000
## 0.21100 59.04 0.306 1.0000
## 0.24500 21.41 -0.788 0.9999
## 0.22000 59.04 0.306 1.0000
## 0.23800 19.45 -2.330 0.5541
## 0.05980 59.00 -3.766 0.0236
## 0.21900 14.41 -2.448 0.4936
## 0.12400 59.00 -3.766 0.0236
## 0.21600 13.67 -2.392 0.5262
## 0.17200 59.00 -3.766 0.0236
## 0.22600 16.12 -2.224 0.6204
## 0.19000 59.00 -3.766 0.0236
## 0.23200 17.81 -2.140 0.6699
## 0.20000 59.00 -3.766 0.0236
## 0.23600 18.88 -2.092 0.6982
## 0.21900 14.30 1.506 0.9452
## 0.05960 59.04 0.306 1.0000
## 0.21500 13.46 0.405 1.0000
## 0.12400 59.04 0.306 1.0000
## 0.22500 15.86 -0.414 1.0000
## 0.17200 59.04 0.306 1.0000
## 0.23100 17.52 -0.702 1.0000
## 0.19000 59.04 0.306 1.0000
## 0.23500 18.59 -0.848 0.9997
## 0.20000 59.04 0.306 1.0000
## 0.19800 9.76 -1.572 0.9189
## 0.06440 59.00 -3.766 0.0236
## 0.19500 9.11 -1.499 0.9371
## 0.11200 59.00 -3.766 0.0236
## 0.20600 11.26 -1.349 0.9714
## 0.13100 59.00 -3.766 0.0236
## 0.21200 12.78 -1.279 0.9820
## 0.14000 59.00 -3.766 0.0236
## 0.21700 13.77 -1.240 0.9864
## 0.19400 9.03 0.355 1.0000
## 0.06420 59.04 0.306 1.0000
## 0.20500 11.14 -0.544 1.0000
## 0.11200 59.04 0.306 1.0000
## 0.21200 12.64 -0.853 0.9995
## 0.13000 59.04 0.306 1.0000
## 0.21600 13.62 -1.007 0.9977
## 0.14000 59.04 0.306 1.0000
## 0.19100 8.40 -0.258 1.0000
## 0.04790 59.00 -3.766 0.0236
## 0.20200 10.49 -0.172 1.0000
## 0.06630 59.00 -3.766 0.0236
## 0.20900 11.98 -0.139 1.0000
## 0.07610 59.00 -3.766 0.0236
## 0.21300 12.95 -0.122 1.0000
## 0.20200 10.45 -0.650 1.0000
## 0.04770 59.04 0.306 1.0000
## 0.20900 11.92 -0.960 0.9984
## 0.06600 59.04 0.306 1.0000
## 0.21300 12.88 -1.115 0.9941
## 0.07580 59.04 0.306 1.0000
## 0.21200 12.72 0.687 1.0000
## 0.01840 59.00 -3.766 0.0236
## 0.21900 14.30 0.692 1.0000
## 0.02820 59.00 -3.766 0.0236
## 0.22300 15.32 0.692 1.0000
## 0.21900 14.28 -0.982 0.9983
## 0.01830 59.04 0.306 1.0000
## 0.22300 15.30 -1.130 0.9941
## 0.02810 59.04 0.306 1.0000
## 0.22500 15.92 0.979 0.9985
## 0.00980 59.00 -3.766 0.0236
## 0.22900 16.97 0.975 0.9986
## 0.22900 16.96 -1.123 0.9948
## 0.00977 59.04 0.306 1.0000
## 0.23300 18.03 1.117 0.9952
##
## Degrees-of-freedom method: kenward-roger
## Results are given on the log (not the response) scale.
## P value adjustment: tukey method for comparing a family of 14 estimates
# ASV RICHNESS PAIRWISE COMPARISONS
# (EMMEANS):#######################################################
# Run emmeans with specified GDD levels
emm_specnumber_interspecific <- emmeans(lmm_model_specnumber3, specs = pairwise ~
Species | GDD_5C, at = list(GDD_5C = gdd_levels))
emm_specnumber_interspecific$emmeans
## GDD_5C = 437:
## Species emmean SE df lower.CL upper.CL
## Betula_populifolia 3.20 0.183 25.57 2.83 3.58
## Populus_tremuloides 3.84 0.181 24.81 3.47 4.21
##
## GDD_5C = 605:
## Species emmean SE df lower.CL upper.CL
## Betula_populifolia 3.28 0.169 19.77 2.93 3.63
## Populus_tremuloides 3.83 0.168 19.13 3.48 4.19
##
## GDD_5C = 1087:
## Species emmean SE df lower.CL upper.CL
## Betula_populifolia 3.50 0.141 9.91 3.19 3.82
## Populus_tremuloides 3.82 0.140 9.60 3.50 4.13
##
## GDD_5C = 1606:
## Species emmean SE df lower.CL upper.CL
## Betula_populifolia 3.75 0.135 8.47 3.44 4.06
## Populus_tremuloides 3.80 0.135 8.33 3.49 4.11
##
## GDD_5C = 1992:
## Species emmean SE df lower.CL upper.CL
## Betula_populifolia 3.93 0.150 12.75 3.60 4.25
## Populus_tremuloides 3.78 0.150 12.68 3.46 4.11
##
## GDD_5C = 2140:
## Species emmean SE df lower.CL upper.CL
## Betula_populifolia 4.00 0.159 15.94 3.66 4.33
## Populus_tremuloides 3.78 0.159 15.89 3.44 4.11
##
## GDD_5C = 2219:
## Species emmean SE df lower.CL upper.CL
## Betula_populifolia 4.03 0.165 18.05 3.69 4.38
## Populus_tremuloides 3.77 0.165 18.01 3.43 4.12
##
## Degrees-of-freedom method: kenward-roger
## Results are given on the log (not the response) scale.
## Confidence level used: 0.95
summary(emm_specnumber_interspecific$contrasts)
## GDD_5C = 437:
## contrast estimate SE df t.ratio p.value
## Betula_populifolia - Populus_tremuloides -0.6399 0.257 25.19 -2.487 0.0198
##
## GDD_5C = 605:
## contrast estimate SE df t.ratio p.value
## Betula_populifolia - Populus_tremuloides -0.5550 0.238 19.45 -2.330 0.0307
##
## GDD_5C = 1087:
## contrast estimate SE df t.ratio p.value
## Betula_populifolia - Populus_tremuloides -0.3115 0.198 9.76 -1.572 0.1478
##
## GDD_5C = 1606:
## contrast estimate SE df t.ratio p.value
## Betula_populifolia - Populus_tremuloides -0.0493 0.191 8.40 -0.258 0.8024
##
## GDD_5C = 1992:
## contrast estimate SE df t.ratio p.value
## Betula_populifolia - Populus_tremuloides 0.1457 0.212 12.72 0.687 0.5044
##
## GDD_5C = 2140:
## contrast estimate SE df t.ratio p.value
## Betula_populifolia - Populus_tremuloides 0.2205 0.225 15.92 0.979 0.3422
##
## GDD_5C = 2219:
## contrast estimate SE df t.ratio p.value
## Betula_populifolia - Populus_tremuloides 0.2604 0.233 18.03 1.117 0.2785
##
## Degrees-of-freedom method: kenward-roger
## Results are given on the log (not the response) scale.
# GDD_5C AS A FACTOR!!! ASV RICHNESS PAIRWISE COMPARISONS
# (EMMEANS):#######################################################
# Define the GDD levels of interest gdd_levels <- c(437, 605, 1087, 1606, 1992,
# 2140, 2219)
# Create new model with GDD_5C_bins
lmm_model_specnumber_GDDbins <- lmer(log(specnumber) ~ Species + GDD_5C_bins + Species:GDD_5C_bins +
(1 | Plant_ID), data = asv_scaled_noPlants_Phen_filt_LMM)
# Run emmeans with specified GDD levels
emm_specnumber_interspecific_GDDbins <- emmeans(lmm_model_specnumber_GDDbins, specs = pairwise ~
Species:GDD_5C_bins)
emm_specnumber_interspecific_GDDbins$emmeans
## Species GDD_5C_bins emmean SE df lower.CL upper.CL
## Betula_populifolia 437 3.25 0.250 49 2.74 3.75
## Populus_tremuloides 437 3.64 0.250 49 3.14 4.15
## Betula_populifolia 605 3.28 0.250 49 2.77 3.78
## Populus_tremuloides 605 4.07 0.250 49 3.57 4.57
## Betula_populifolia 1087 3.40 0.250 49 2.90 3.90
## Populus_tremuloides 1087 3.94 0.234 44 3.47 4.41
## Betula_populifolia 1606 3.77 0.250 49 3.26 4.27
## Populus_tremuloides 1606 3.56 0.250 49 3.06 4.06
## Betula_populifolia 1992 4.07 0.250 49 3.56 4.57
## Populus_tremuloides 1992 3.47 0.250 49 2.97 3.98
## Betula_populifolia 2140 3.98 0.250 49 3.47 4.48
## Populus_tremuloides 2140 4.06 0.250 49 3.56 4.56
## Betula_populifolia 2219 3.96 0.250 49 3.46 4.46
## Populus_tremuloides 2219 3.85 0.250 49 3.35 4.36
##
## Degrees-of-freedom method: kenward-roger
## Results are given on the log (not the response) scale.
## Confidence level used: 0.95
summary(emm_specnumber_interspecific_GDDbins$contrasts)
## contrast
## Betula_populifolia GDD_5C_bins437 - Populus_tremuloides GDD_5C_bins437
## Betula_populifolia GDD_5C_bins437 - Betula_populifolia GDD_5C_bins605
## Betula_populifolia GDD_5C_bins437 - Populus_tremuloides GDD_5C_bins605
## Betula_populifolia GDD_5C_bins437 - Betula_populifolia GDD_5C_bins1087
## Betula_populifolia GDD_5C_bins437 - Populus_tremuloides GDD_5C_bins1087
## Betula_populifolia GDD_5C_bins437 - Betula_populifolia GDD_5C_bins1606
## Betula_populifolia GDD_5C_bins437 - Populus_tremuloides GDD_5C_bins1606
## Betula_populifolia GDD_5C_bins437 - Betula_populifolia GDD_5C_bins1992
## Betula_populifolia GDD_5C_bins437 - Populus_tremuloides GDD_5C_bins1992
## Betula_populifolia GDD_5C_bins437 - Betula_populifolia GDD_5C_bins2140
## Betula_populifolia GDD_5C_bins437 - Populus_tremuloides GDD_5C_bins2140
## Betula_populifolia GDD_5C_bins437 - Betula_populifolia GDD_5C_bins2219
## Betula_populifolia GDD_5C_bins437 - Populus_tremuloides GDD_5C_bins2219
## Populus_tremuloides GDD_5C_bins437 - Betula_populifolia GDD_5C_bins605
## Populus_tremuloides GDD_5C_bins437 - Populus_tremuloides GDD_5C_bins605
## Populus_tremuloides GDD_5C_bins437 - Betula_populifolia GDD_5C_bins1087
## Populus_tremuloides GDD_5C_bins437 - Populus_tremuloides GDD_5C_bins1087
## Populus_tremuloides GDD_5C_bins437 - Betula_populifolia GDD_5C_bins1606
## Populus_tremuloides GDD_5C_bins437 - Populus_tremuloides GDD_5C_bins1606
## Populus_tremuloides GDD_5C_bins437 - Betula_populifolia GDD_5C_bins1992
## Populus_tremuloides GDD_5C_bins437 - Populus_tremuloides GDD_5C_bins1992
## Populus_tremuloides GDD_5C_bins437 - Betula_populifolia GDD_5C_bins2140
## Populus_tremuloides GDD_5C_bins437 - Populus_tremuloides GDD_5C_bins2140
## Populus_tremuloides GDD_5C_bins437 - Betula_populifolia GDD_5C_bins2219
## Populus_tremuloides GDD_5C_bins437 - Populus_tremuloides GDD_5C_bins2219
## Betula_populifolia GDD_5C_bins605 - Populus_tremuloides GDD_5C_bins605
## Betula_populifolia GDD_5C_bins605 - Betula_populifolia GDD_5C_bins1087
## Betula_populifolia GDD_5C_bins605 - Populus_tremuloides GDD_5C_bins1087
## Betula_populifolia GDD_5C_bins605 - Betula_populifolia GDD_5C_bins1606
## Betula_populifolia GDD_5C_bins605 - Populus_tremuloides GDD_5C_bins1606
## Betula_populifolia GDD_5C_bins605 - Betula_populifolia GDD_5C_bins1992
## Betula_populifolia GDD_5C_bins605 - Populus_tremuloides GDD_5C_bins1992
## Betula_populifolia GDD_5C_bins605 - Betula_populifolia GDD_5C_bins2140
## Betula_populifolia GDD_5C_bins605 - Populus_tremuloides GDD_5C_bins2140
## Betula_populifolia GDD_5C_bins605 - Betula_populifolia GDD_5C_bins2219
## Betula_populifolia GDD_5C_bins605 - Populus_tremuloides GDD_5C_bins2219
## Populus_tremuloides GDD_5C_bins605 - Betula_populifolia GDD_5C_bins1087
## Populus_tremuloides GDD_5C_bins605 - Populus_tremuloides GDD_5C_bins1087
## Populus_tremuloides GDD_5C_bins605 - Betula_populifolia GDD_5C_bins1606
## Populus_tremuloides GDD_5C_bins605 - Populus_tremuloides GDD_5C_bins1606
## Populus_tremuloides GDD_5C_bins605 - Betula_populifolia GDD_5C_bins1992
## Populus_tremuloides GDD_5C_bins605 - Populus_tremuloides GDD_5C_bins1992
## Populus_tremuloides GDD_5C_bins605 - Betula_populifolia GDD_5C_bins2140
## Populus_tremuloides GDD_5C_bins605 - Populus_tremuloides GDD_5C_bins2140
## Populus_tremuloides GDD_5C_bins605 - Betula_populifolia GDD_5C_bins2219
## Populus_tremuloides GDD_5C_bins605 - Populus_tremuloides GDD_5C_bins2219
## Betula_populifolia GDD_5C_bins1087 - Populus_tremuloides GDD_5C_bins1087
## Betula_populifolia GDD_5C_bins1087 - Betula_populifolia GDD_5C_bins1606
## Betula_populifolia GDD_5C_bins1087 - Populus_tremuloides GDD_5C_bins1606
## Betula_populifolia GDD_5C_bins1087 - Betula_populifolia GDD_5C_bins1992
## Betula_populifolia GDD_5C_bins1087 - Populus_tremuloides GDD_5C_bins1992
## Betula_populifolia GDD_5C_bins1087 - Betula_populifolia GDD_5C_bins2140
## Betula_populifolia GDD_5C_bins1087 - Populus_tremuloides GDD_5C_bins2140
## Betula_populifolia GDD_5C_bins1087 - Betula_populifolia GDD_5C_bins2219
## Betula_populifolia GDD_5C_bins1087 - Populus_tremuloides GDD_5C_bins2219
## Populus_tremuloides GDD_5C_bins1087 - Betula_populifolia GDD_5C_bins1606
## Populus_tremuloides GDD_5C_bins1087 - Populus_tremuloides GDD_5C_bins1606
## Populus_tremuloides GDD_5C_bins1087 - Betula_populifolia GDD_5C_bins1992
## Populus_tremuloides GDD_5C_bins1087 - Populus_tremuloides GDD_5C_bins1992
## Populus_tremuloides GDD_5C_bins1087 - Betula_populifolia GDD_5C_bins2140
## Populus_tremuloides GDD_5C_bins1087 - Populus_tremuloides GDD_5C_bins2140
## Populus_tremuloides GDD_5C_bins1087 - Betula_populifolia GDD_5C_bins2219
## Populus_tremuloides GDD_5C_bins1087 - Populus_tremuloides GDD_5C_bins2219
## Betula_populifolia GDD_5C_bins1606 - Populus_tremuloides GDD_5C_bins1606
## Betula_populifolia GDD_5C_bins1606 - Betula_populifolia GDD_5C_bins1992
## Betula_populifolia GDD_5C_bins1606 - Populus_tremuloides GDD_5C_bins1992
## Betula_populifolia GDD_5C_bins1606 - Betula_populifolia GDD_5C_bins2140
## Betula_populifolia GDD_5C_bins1606 - Populus_tremuloides GDD_5C_bins2140
## Betula_populifolia GDD_5C_bins1606 - Betula_populifolia GDD_5C_bins2219
## Betula_populifolia GDD_5C_bins1606 - Populus_tremuloides GDD_5C_bins2219
## Populus_tremuloides GDD_5C_bins1606 - Betula_populifolia GDD_5C_bins1992
## Populus_tremuloides GDD_5C_bins1606 - Populus_tremuloides GDD_5C_bins1992
## Populus_tremuloides GDD_5C_bins1606 - Betula_populifolia GDD_5C_bins2140
## Populus_tremuloides GDD_5C_bins1606 - Populus_tremuloides GDD_5C_bins2140
## Populus_tremuloides GDD_5C_bins1606 - Betula_populifolia GDD_5C_bins2219
## Populus_tremuloides GDD_5C_bins1606 - Populus_tremuloides GDD_5C_bins2219
## Betula_populifolia GDD_5C_bins1992 - Populus_tremuloides GDD_5C_bins1992
## Betula_populifolia GDD_5C_bins1992 - Betula_populifolia GDD_5C_bins2140
## Betula_populifolia GDD_5C_bins1992 - Populus_tremuloides GDD_5C_bins2140
## Betula_populifolia GDD_5C_bins1992 - Betula_populifolia GDD_5C_bins2219
## Betula_populifolia GDD_5C_bins1992 - Populus_tremuloides GDD_5C_bins2219
## Populus_tremuloides GDD_5C_bins1992 - Betula_populifolia GDD_5C_bins2140
## Populus_tremuloides GDD_5C_bins1992 - Populus_tremuloides GDD_5C_bins2140
## Populus_tremuloides GDD_5C_bins1992 - Betula_populifolia GDD_5C_bins2219
## Populus_tremuloides GDD_5C_bins1992 - Populus_tremuloides GDD_5C_bins2219
## Betula_populifolia GDD_5C_bins2140 - Populus_tremuloides GDD_5C_bins2140
## Betula_populifolia GDD_5C_bins2140 - Betula_populifolia GDD_5C_bins2219
## Betula_populifolia GDD_5C_bins2140 - Populus_tremuloides GDD_5C_bins2219
## Populus_tremuloides GDD_5C_bins2140 - Betula_populifolia GDD_5C_bins2219
## Populus_tremuloides GDD_5C_bins2140 - Populus_tremuloides GDD_5C_bins2219
## Betula_populifolia GDD_5C_bins2219 - Populus_tremuloides GDD_5C_bins2219
## estimate SE df t.ratio p.value
## -0.39556 0.354 49.0 -1.117 0.9970
## -0.02846 0.324 49.0 -0.088 1.0000
## -0.82089 0.354 49.0 -2.317 0.5509
## -0.15179 0.324 49.0 -0.468 1.0000
## -0.69313 0.343 46.8 -2.023 0.7457
## -0.51795 0.324 49.0 -1.597 0.9385
## -0.31331 0.354 49.0 -0.884 0.9997
## -0.81776 0.324 49.0 -2.522 0.4151
## -0.22571 0.354 49.0 -0.637 1.0000
## -0.72883 0.324 49.0 -2.247 0.5988
## -0.81095 0.354 49.0 -2.289 0.5701
## -0.71206 0.324 49.0 -2.196 0.6340
## -0.60410 0.354 49.0 -1.705 0.9040
## 0.36711 0.354 49.0 1.036 0.9986
## -0.42532 0.324 49.0 -1.311 0.9870
## 0.24378 0.354 49.0 0.688 1.0000
## -0.29757 0.312 49.3 -0.955 0.9994
## -0.12238 0.354 49.0 -0.345 1.0000
## 0.08225 0.324 49.0 0.254 1.0000
## -0.42220 0.354 49.0 -1.192 0.9945
## 0.16985 0.324 49.0 0.524 1.0000
## -0.33326 0.354 49.0 -0.941 0.9995
## -0.41539 0.324 49.0 -1.281 0.9894
## -0.31650 0.354 49.0 -0.893 0.9997
## -0.20854 0.324 49.0 -0.643 1.0000
## -0.79243 0.354 49.0 -2.237 0.6059
## -0.12333 0.324 49.0 -0.380 1.0000
## -0.66468 0.343 46.8 -1.940 0.7942
## -0.48949 0.324 49.0 -1.509 0.9594
## -0.28485 0.354 49.0 -0.804 0.9999
## -0.78931 0.324 49.0 -2.434 0.4721
## -0.19726 0.354 49.0 -0.557 1.0000
## -0.70037 0.324 49.0 -2.160 0.6583
## -0.78250 0.354 49.0 -2.209 0.6250
## -0.68360 0.324 49.0 -2.108 0.6924
## -0.57565 0.354 49.0 -1.625 0.9306
## 0.66910 0.354 49.0 1.889 0.8224
## 0.12775 0.312 49.3 0.410 1.0000
## 0.30294 0.354 49.0 0.855 0.9998
## 0.50757 0.324 49.0 1.565 0.9468
## 0.00312 0.354 49.0 0.009 1.0000
## 0.59517 0.324 49.0 1.835 0.8492
## 0.09206 0.354 49.0 0.260 1.0000
## 0.00993 0.324 49.0 0.031 1.0000
## 0.10882 0.354 49.0 0.307 1.0000
## 0.21678 0.324 49.0 0.668 1.0000
## -0.54134 0.343 46.8 -1.580 0.9427
## -0.36616 0.324 49.0 -1.129 0.9967
## -0.16152 0.354 49.0 -0.456 1.0000
## -0.66598 0.324 49.0 -2.054 0.7272
## -0.07392 0.354 49.0 -0.209 1.0000
## -0.57704 0.324 49.0 -1.779 0.8746
## -0.65916 0.354 49.0 -1.861 0.8367
## -0.56027 0.324 49.0 -1.728 0.8957
## -0.45232 0.354 49.0 -1.277 0.9897
## 0.17519 0.343 46.8 0.511 1.0000
## 0.37982 0.312 49.3 1.219 0.9932
## -0.12463 0.343 46.8 -0.364 1.0000
## 0.46742 0.312 49.3 1.500 0.9612
## -0.03569 0.343 46.8 -0.104 1.0000
## -0.11782 0.312 49.3 -0.378 1.0000
## -0.01893 0.343 46.8 -0.055 1.0000
## 0.08903 0.312 49.3 0.286 1.0000
## 0.20463 0.354 49.0 0.578 1.0000
## -0.29982 0.324 49.0 -0.924 0.9996
## 0.29223 0.354 49.0 0.825 0.9999
## -0.21088 0.324 49.0 -0.650 1.0000
## -0.29301 0.354 49.0 -0.827 0.9999
## -0.19412 0.324 49.0 -0.599 1.0000
## -0.08616 0.354 49.0 -0.243 1.0000
## -0.50445 0.354 49.0 -1.424 0.9742
## 0.08760 0.324 49.0 0.270 1.0000
## -0.41552 0.354 49.0 -1.173 0.9952
## -0.49764 0.324 49.0 -1.534 0.9540
## -0.39875 0.354 49.0 -1.126 0.9968
## -0.29079 0.324 49.0 -0.897 0.9997
## 0.59205 0.354 49.0 1.671 0.9160
## 0.08894 0.324 49.0 0.274 1.0000
## 0.00681 0.354 49.0 0.019 1.0000
## 0.10570 0.324 49.0 0.326 1.0000
## 0.21366 0.354 49.0 0.603 1.0000
## -0.50312 0.354 49.0 -1.420 0.9747
## -0.58524 0.324 49.0 -1.805 0.8634
## -0.48635 0.354 49.0 -1.373 0.9808
## -0.37839 0.324 49.0 -1.167 0.9955
## -0.08212 0.354 49.0 -0.232 1.0000
## 0.01677 0.324 49.0 0.052 1.0000
## 0.12472 0.354 49.0 0.352 1.0000
## 0.09889 0.354 49.0 0.279 1.0000
## 0.20685 0.324 49.0 0.638 1.0000
## 0.10796 0.354 49.0 0.305 1.0000
##
## Degrees-of-freedom method: kenward-roger
## Results are given on the log (not the response) scale.
## P value adjustment: tukey method for comparing a family of 14 estimates
# FACTORIZED:
# Create a copy of the original data frame
asv_scaled_noPlants_Phen_filt_LMM_factor <- asv_scaled_noPlants_Phen_filt_LMM
# Convert GDD_5C to a factor in the new data frame only
asv_scaled_noPlants_Phen_filt_LMM_factor$GDD_5C <- factor(asv_scaled_noPlants_Phen_filt_LMM_factor$GDD_5C)
# Run LMM:
lmm_model_specnumber_GDDfactor <- lmer(log(specnumber) ~ Species + GDD_5C + Species:GDD_5C +
(1 | Plant_ID), data = asv_scaled_noPlants_Phen_filt_LMM_factor)
# Run emmeans with specified GDD levels
emm_specnumber_interspecific_GDDfactor <- emmeans(lmm_model_specnumber_GDDfactor,
specs = pairwise ~ Species:GDD_5C)
emm_specnumber_interspecific_GDDfactor$emmeans
## Species GDD_5C emmean SE df lower.CL upper.CL
## Betula_populifolia 437 3.25 0.250 49 2.74 3.75
## Populus_tremuloides 437 3.64 0.250 49 3.14 4.15
## Betula_populifolia 605 3.28 0.250 49 2.77 3.78
## Populus_tremuloides 605 4.07 0.250 49 3.57 4.57
## Betula_populifolia 1087 3.40 0.250 49 2.90 3.90
## Populus_tremuloides 1087 3.94 0.234 44 3.47 4.41
## Betula_populifolia 1606 3.77 0.250 49 3.26 4.27
## Populus_tremuloides 1606 3.56 0.250 49 3.06 4.06
## Betula_populifolia 1992 4.07 0.250 49 3.56 4.57
## Populus_tremuloides 1992 3.47 0.250 49 2.97 3.98
## Betula_populifolia 2140 3.98 0.250 49 3.47 4.48
## Populus_tremuloides 2140 4.06 0.250 49 3.56 4.56
## Betula_populifolia 2219 3.96 0.250 49 3.46 4.46
## Populus_tremuloides 2219 3.85 0.250 49 3.35 4.36
##
## Degrees-of-freedom method: kenward-roger
## Results are given on the log (not the response) scale.
## Confidence level used: 0.95
summary(emm_specnumber_interspecific_GDDfactor$contrasts)
## contrast estimate SE
## Betula_populifolia GDD_5C437 - Populus_tremuloides GDD_5C437 -0.39556 0.354
## Betula_populifolia GDD_5C437 - Betula_populifolia GDD_5C605 -0.02846 0.324
## Betula_populifolia GDD_5C437 - Populus_tremuloides GDD_5C605 -0.82089 0.354
## Betula_populifolia GDD_5C437 - Betula_populifolia GDD_5C1087 -0.15179 0.324
## Betula_populifolia GDD_5C437 - Populus_tremuloides GDD_5C1087 -0.69313 0.343
## Betula_populifolia GDD_5C437 - Betula_populifolia GDD_5C1606 -0.51795 0.324
## Betula_populifolia GDD_5C437 - Populus_tremuloides GDD_5C1606 -0.31331 0.354
## Betula_populifolia GDD_5C437 - Betula_populifolia GDD_5C1992 -0.81776 0.324
## Betula_populifolia GDD_5C437 - Populus_tremuloides GDD_5C1992 -0.22571 0.354
## Betula_populifolia GDD_5C437 - Betula_populifolia GDD_5C2140 -0.72883 0.324
## Betula_populifolia GDD_5C437 - Populus_tremuloides GDD_5C2140 -0.81095 0.354
## Betula_populifolia GDD_5C437 - Betula_populifolia GDD_5C2219 -0.71206 0.324
## Betula_populifolia GDD_5C437 - Populus_tremuloides GDD_5C2219 -0.60410 0.354
## Populus_tremuloides GDD_5C437 - Betula_populifolia GDD_5C605 0.36711 0.354
## Populus_tremuloides GDD_5C437 - Populus_tremuloides GDD_5C605 -0.42532 0.324
## Populus_tremuloides GDD_5C437 - Betula_populifolia GDD_5C1087 0.24378 0.354
## Populus_tremuloides GDD_5C437 - Populus_tremuloides GDD_5C1087 -0.29757 0.312
## Populus_tremuloides GDD_5C437 - Betula_populifolia GDD_5C1606 -0.12238 0.354
## Populus_tremuloides GDD_5C437 - Populus_tremuloides GDD_5C1606 0.08225 0.324
## Populus_tremuloides GDD_5C437 - Betula_populifolia GDD_5C1992 -0.42220 0.354
## Populus_tremuloides GDD_5C437 - Populus_tremuloides GDD_5C1992 0.16985 0.324
## Populus_tremuloides GDD_5C437 - Betula_populifolia GDD_5C2140 -0.33326 0.354
## Populus_tremuloides GDD_5C437 - Populus_tremuloides GDD_5C2140 -0.41539 0.324
## Populus_tremuloides GDD_5C437 - Betula_populifolia GDD_5C2219 -0.31650 0.354
## Populus_tremuloides GDD_5C437 - Populus_tremuloides GDD_5C2219 -0.20854 0.324
## Betula_populifolia GDD_5C605 - Populus_tremuloides GDD_5C605 -0.79243 0.354
## Betula_populifolia GDD_5C605 - Betula_populifolia GDD_5C1087 -0.12333 0.324
## Betula_populifolia GDD_5C605 - Populus_tremuloides GDD_5C1087 -0.66468 0.343
## Betula_populifolia GDD_5C605 - Betula_populifolia GDD_5C1606 -0.48949 0.324
## Betula_populifolia GDD_5C605 - Populus_tremuloides GDD_5C1606 -0.28485 0.354
## Betula_populifolia GDD_5C605 - Betula_populifolia GDD_5C1992 -0.78931 0.324
## Betula_populifolia GDD_5C605 - Populus_tremuloides GDD_5C1992 -0.19726 0.354
## Betula_populifolia GDD_5C605 - Betula_populifolia GDD_5C2140 -0.70037 0.324
## Betula_populifolia GDD_5C605 - Populus_tremuloides GDD_5C2140 -0.78250 0.354
## Betula_populifolia GDD_5C605 - Betula_populifolia GDD_5C2219 -0.68360 0.324
## Betula_populifolia GDD_5C605 - Populus_tremuloides GDD_5C2219 -0.57565 0.354
## Populus_tremuloides GDD_5C605 - Betula_populifolia GDD_5C1087 0.66910 0.354
## Populus_tremuloides GDD_5C605 - Populus_tremuloides GDD_5C1087 0.12775 0.312
## Populus_tremuloides GDD_5C605 - Betula_populifolia GDD_5C1606 0.30294 0.354
## Populus_tremuloides GDD_5C605 - Populus_tremuloides GDD_5C1606 0.50757 0.324
## Populus_tremuloides GDD_5C605 - Betula_populifolia GDD_5C1992 0.00312 0.354
## Populus_tremuloides GDD_5C605 - Populus_tremuloides GDD_5C1992 0.59517 0.324
## Populus_tremuloides GDD_5C605 - Betula_populifolia GDD_5C2140 0.09206 0.354
## Populus_tremuloides GDD_5C605 - Populus_tremuloides GDD_5C2140 0.00993 0.324
## Populus_tremuloides GDD_5C605 - Betula_populifolia GDD_5C2219 0.10882 0.354
## Populus_tremuloides GDD_5C605 - Populus_tremuloides GDD_5C2219 0.21678 0.324
## Betula_populifolia GDD_5C1087 - Populus_tremuloides GDD_5C1087 -0.54134 0.343
## Betula_populifolia GDD_5C1087 - Betula_populifolia GDD_5C1606 -0.36616 0.324
## Betula_populifolia GDD_5C1087 - Populus_tremuloides GDD_5C1606 -0.16152 0.354
## Betula_populifolia GDD_5C1087 - Betula_populifolia GDD_5C1992 -0.66598 0.324
## Betula_populifolia GDD_5C1087 - Populus_tremuloides GDD_5C1992 -0.07392 0.354
## Betula_populifolia GDD_5C1087 - Betula_populifolia GDD_5C2140 -0.57704 0.324
## Betula_populifolia GDD_5C1087 - Populus_tremuloides GDD_5C2140 -0.65916 0.354
## Betula_populifolia GDD_5C1087 - Betula_populifolia GDD_5C2219 -0.56027 0.324
## Betula_populifolia GDD_5C1087 - Populus_tremuloides GDD_5C2219 -0.45232 0.354
## Populus_tremuloides GDD_5C1087 - Betula_populifolia GDD_5C1606 0.17519 0.343
## Populus_tremuloides GDD_5C1087 - Populus_tremuloides GDD_5C1606 0.37982 0.312
## Populus_tremuloides GDD_5C1087 - Betula_populifolia GDD_5C1992 -0.12463 0.343
## Populus_tremuloides GDD_5C1087 - Populus_tremuloides GDD_5C1992 0.46742 0.312
## Populus_tremuloides GDD_5C1087 - Betula_populifolia GDD_5C2140 -0.03569 0.343
## Populus_tremuloides GDD_5C1087 - Populus_tremuloides GDD_5C2140 -0.11782 0.312
## Populus_tremuloides GDD_5C1087 - Betula_populifolia GDD_5C2219 -0.01893 0.343
## Populus_tremuloides GDD_5C1087 - Populus_tremuloides GDD_5C2219 0.08903 0.312
## Betula_populifolia GDD_5C1606 - Populus_tremuloides GDD_5C1606 0.20463 0.354
## Betula_populifolia GDD_5C1606 - Betula_populifolia GDD_5C1992 -0.29982 0.324
## Betula_populifolia GDD_5C1606 - Populus_tremuloides GDD_5C1992 0.29223 0.354
## Betula_populifolia GDD_5C1606 - Betula_populifolia GDD_5C2140 -0.21088 0.324
## Betula_populifolia GDD_5C1606 - Populus_tremuloides GDD_5C2140 -0.29301 0.354
## Betula_populifolia GDD_5C1606 - Betula_populifolia GDD_5C2219 -0.19412 0.324
## Betula_populifolia GDD_5C1606 - Populus_tremuloides GDD_5C2219 -0.08616 0.354
## Populus_tremuloides GDD_5C1606 - Betula_populifolia GDD_5C1992 -0.50445 0.354
## Populus_tremuloides GDD_5C1606 - Populus_tremuloides GDD_5C1992 0.08760 0.324
## Populus_tremuloides GDD_5C1606 - Betula_populifolia GDD_5C2140 -0.41552 0.354
## Populus_tremuloides GDD_5C1606 - Populus_tremuloides GDD_5C2140 -0.49764 0.324
## Populus_tremuloides GDD_5C1606 - Betula_populifolia GDD_5C2219 -0.39875 0.354
## Populus_tremuloides GDD_5C1606 - Populus_tremuloides GDD_5C2219 -0.29079 0.324
## Betula_populifolia GDD_5C1992 - Populus_tremuloides GDD_5C1992 0.59205 0.354
## Betula_populifolia GDD_5C1992 - Betula_populifolia GDD_5C2140 0.08894 0.324
## Betula_populifolia GDD_5C1992 - Populus_tremuloides GDD_5C2140 0.00681 0.354
## Betula_populifolia GDD_5C1992 - Betula_populifolia GDD_5C2219 0.10570 0.324
## Betula_populifolia GDD_5C1992 - Populus_tremuloides GDD_5C2219 0.21366 0.354
## Populus_tremuloides GDD_5C1992 - Betula_populifolia GDD_5C2140 -0.50312 0.354
## Populus_tremuloides GDD_5C1992 - Populus_tremuloides GDD_5C2140 -0.58524 0.324
## Populus_tremuloides GDD_5C1992 - Betula_populifolia GDD_5C2219 -0.48635 0.354
## Populus_tremuloides GDD_5C1992 - Populus_tremuloides GDD_5C2219 -0.37839 0.324
## Betula_populifolia GDD_5C2140 - Populus_tremuloides GDD_5C2140 -0.08212 0.354
## Betula_populifolia GDD_5C2140 - Betula_populifolia GDD_5C2219 0.01677 0.324
## Betula_populifolia GDD_5C2140 - Populus_tremuloides GDD_5C2219 0.12472 0.354
## Populus_tremuloides GDD_5C2140 - Betula_populifolia GDD_5C2219 0.09889 0.354
## Populus_tremuloides GDD_5C2140 - Populus_tremuloides GDD_5C2219 0.20685 0.324
## Betula_populifolia GDD_5C2219 - Populus_tremuloides GDD_5C2219 0.10796 0.354
## df t.ratio p.value
## 49.0 -1.117 0.9970
## 49.0 -0.088 1.0000
## 49.0 -2.317 0.5509
## 49.0 -0.468 1.0000
## 46.8 -2.023 0.7457
## 49.0 -1.597 0.9385
## 49.0 -0.884 0.9997
## 49.0 -2.522 0.4151
## 49.0 -0.637 1.0000
## 49.0 -2.247 0.5988
## 49.0 -2.289 0.5701
## 49.0 -2.196 0.6340
## 49.0 -1.705 0.9040
## 49.0 1.036 0.9986
## 49.0 -1.311 0.9870
## 49.0 0.688 1.0000
## 49.3 -0.955 0.9994
## 49.0 -0.345 1.0000
## 49.0 0.254 1.0000
## 49.0 -1.192 0.9945
## 49.0 0.524 1.0000
## 49.0 -0.941 0.9995
## 49.0 -1.281 0.9894
## 49.0 -0.893 0.9997
## 49.0 -0.643 1.0000
## 49.0 -2.237 0.6059
## 49.0 -0.380 1.0000
## 46.8 -1.940 0.7942
## 49.0 -1.509 0.9594
## 49.0 -0.804 0.9999
## 49.0 -2.434 0.4721
## 49.0 -0.557 1.0000
## 49.0 -2.160 0.6583
## 49.0 -2.209 0.6250
## 49.0 -2.108 0.6924
## 49.0 -1.625 0.9306
## 49.0 1.889 0.8224
## 49.3 0.410 1.0000
## 49.0 0.855 0.9998
## 49.0 1.565 0.9468
## 49.0 0.009 1.0000
## 49.0 1.835 0.8492
## 49.0 0.260 1.0000
## 49.0 0.031 1.0000
## 49.0 0.307 1.0000
## 49.0 0.668 1.0000
## 46.8 -1.580 0.9427
## 49.0 -1.129 0.9967
## 49.0 -0.456 1.0000
## 49.0 -2.054 0.7272
## 49.0 -0.209 1.0000
## 49.0 -1.779 0.8746
## 49.0 -1.861 0.8367
## 49.0 -1.728 0.8957
## 49.0 -1.277 0.9897
## 46.8 0.511 1.0000
## 49.3 1.219 0.9932
## 46.8 -0.364 1.0000
## 49.3 1.500 0.9612
## 46.8 -0.104 1.0000
## 49.3 -0.378 1.0000
## 46.8 -0.055 1.0000
## 49.3 0.286 1.0000
## 49.0 0.578 1.0000
## 49.0 -0.924 0.9996
## 49.0 0.825 0.9999
## 49.0 -0.650 1.0000
## 49.0 -0.827 0.9999
## 49.0 -0.599 1.0000
## 49.0 -0.243 1.0000
## 49.0 -1.424 0.9742
## 49.0 0.270 1.0000
## 49.0 -1.173 0.9952
## 49.0 -1.534 0.9540
## 49.0 -1.126 0.9968
## 49.0 -0.897 0.9997
## 49.0 1.671 0.9160
## 49.0 0.274 1.0000
## 49.0 0.019 1.0000
## 49.0 0.326 1.0000
## 49.0 0.603 1.0000
## 49.0 -1.420 0.9747
## 49.0 -1.805 0.8634
## 49.0 -1.373 0.9808
## 49.0 -1.167 0.9955
## 49.0 -0.232 1.0000
## 49.0 0.052 1.0000
## 49.0 0.352 1.0000
## 49.0 0.279 1.0000
## 49.0 0.638 1.0000
## 49.0 0.305 1.0000
##
## Degrees-of-freedom method: kenward-roger
## Results are given on the log (not the response) scale.
## P value adjustment: tukey method for comparing a family of 14 estimates
# SHANNON DIVERSITY PAIRWISE COMPARISONS
# (EMMEANS):#######################################################
# Define the GDD levels of interest
gdd_levels <- c(437, 605, 1087, 1606, 1992, 2140, 2219)
# Run emmeans with specified GDD levels
emm_shannon_interspecific <- emmeans(lmm_model_shannon2, specs = pairwise ~ Species |
GDD_5C, at = list(GDD_5C = gdd_levels))
emm_shannon_interspecific$emmeans
## GDD_5C = 437:
## Species emmean SE df lower.CL upper.CL
## Betula_populifolia 1.57 0.0719 32.86 1.43 1.72
## Populus_tremuloides 1.84 0.0712 31.80 1.69 1.98
##
## GDD_5C = 605:
## Species emmean SE df lower.CL upper.CL
## Betula_populifolia 1.57 0.0656 24.94 1.44 1.71
## Populus_tremuloides 1.83 0.0650 23.99 1.70 1.97
##
## GDD_5C = 1087:
## Species emmean SE df lower.CL upper.CL
## Betula_populifolia 1.57 0.0519 10.70 1.45 1.68
## Populus_tremuloides 1.83 0.0514 10.25 1.72 1.94
##
## GDD_5C = 1606:
## Species emmean SE df lower.CL upper.CL
## Betula_populifolia 1.56 0.0492 8.66 1.45 1.67
## Populus_tremuloides 1.82 0.0490 8.46 1.71 1.94
##
## GDD_5C = 1992:
## Species emmean SE df lower.CL upper.CL
## Betula_populifolia 1.56 0.0566 14.82 1.44 1.68
## Populus_tremuloides 1.82 0.0565 14.71 1.70 1.94
##
## GDD_5C = 2140:
## Species emmean SE df lower.CL upper.CL
## Betula_populifolia 1.56 0.0610 19.46 1.43 1.68
## Populus_tremuloides 1.82 0.0609 19.39 1.69 1.95
##
## GDD_5C = 2219:
## Species emmean SE df lower.CL upper.CL
## Betula_populifolia 1.56 0.0636 22.50 1.42 1.69
## Populus_tremuloides 1.82 0.0636 22.44 1.69 1.95
##
## Degrees-of-freedom method: kenward-roger
## Results are given on the sqrt (not the response) scale.
## Confidence level used: 0.95
summary(emm_shannon_interspecific$contrasts)
## GDD_5C = 437:
## contrast estimate SE df t.ratio p.value
## Betula_populifolia - Populus_tremuloides -0.264 0.1010 32.33 -2.604 0.0138
##
## GDD_5C = 605:
## contrast estimate SE df t.ratio p.value
## Betula_populifolia - Populus_tremuloides -0.263 0.0923 24.46 -2.853 0.0087
##
## GDD_5C = 1087:
## contrast estimate SE df t.ratio p.value
## Betula_populifolia - Populus_tremuloides -0.263 0.0731 10.47 -3.597 0.0045
##
## GDD_5C = 1606:
## contrast estimate SE df t.ratio p.value
## Betula_populifolia - Populus_tremuloides -0.262 0.0694 8.56 -3.778 0.0048
##
## GDD_5C = 1992:
## contrast estimate SE df t.ratio p.value
## Betula_populifolia - Populus_tremuloides -0.262 0.0799 14.76 -3.276 0.0052
##
## GDD_5C = 2140:
## contrast estimate SE df t.ratio p.value
## Betula_populifolia - Populus_tremuloides -0.262 0.0862 19.42 -3.035 0.0067
##
## GDD_5C = 2219:
## contrast estimate SE df t.ratio p.value
## Betula_populifolia - Populus_tremuloides -0.262 0.0899 22.47 -2.908 0.0080
##
## Note: contrasts are still on the sqrt scale. Consider using
## regrid() if you want contrasts of back-transformed estimates.
## Degrees-of-freedom method: kenward-roger
library(RColorBrewer)
library(ggplot2)
library(cowplot)
library(ggsignif)
library(ggpubr)
library(ggplot2)
library(ggpubr)
library(tidyverse)
library(vegan)
library(olsrr)
library(ggsignif)
library(lattice)
library(permute)
library(Hmisc)
library(ecodist)
##For Species:
# Calculate the multidispersion within data (Calculating significance of
# `Species`)
phen.disper.spp = betadisper(dist.mat, asv_scaled_noPlants_Phen_filt_LMM$Species,
type = "centroid")
phen.disper.spp
##
## Homogeneity of multivariate dispersions
##
## Call: betadisper(d = dist.mat, group =
## asv_scaled_noPlants_Phen_filt_LMM$Species, type = "centroid")
##
## No. of Positive Eigenvalues: 68
## No. of Negative Eigenvalues: 2
##
## Average distance to centroid:
## Betula_populifolia Populus_tremuloides
## 0.5855 0.6448
##
## Eigenvalues for PCoA axes:
## (Showing 8 of 70 eigenvalues)
## PCoA1 PCoA2 PCoA3 PCoA4 PCoA5 PCoA6 PCoA7 PCoA8
## 3.8467 3.1659 1.3542 1.0663 1.0103 0.9364 0.7918 0.7372
summary(phen.disper.spp)
## Length Class Mode
## eig 70 -none- numeric
## vectors 4970 -none- numeric
## distances 71 -none- numeric
## group 71 factor numeric
## centroids 140 -none- numeric
## group.distances 2 -none- numeric
## call 4 -none- call
permutest(phen.disper.spp, permutations = 10000)
##
## Permutation test for homogeneity of multivariate dispersions
## Permutation: free
## Number of permutations: 10000
##
## Response: Distances
## Df Sum Sq Mean Sq F N.Perm Pr(>F)
## Groups 1 0.062404 0.062404 22.751 10000 9.999e-05 ***
## Residuals 69 0.189262 0.002743
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
anova(phen.disper.spp)
## Analysis of Variance Table
##
## Response: Distances
## Df Sum Sq Mean Sq F value Pr(>F)
## Groups 1 0.062404 0.062404 22.751 9.932e-06 ***
## Residuals 69 0.189262 0.002743
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
plot(phen.disper.spp)
# Save as PNG
png("phen_disper_spp_pcoa.png", width = 7, height = 4.85, units = "in", res = 600) # Dimensions in inches, 300 DPI
plot(phen.disper.spp) # Generate the plot
dev.off()
boxplot(phen.disper.spp, xlab = "Species")
# Save as PNG
png("phen_disper_spp_boxplot.png", width = 7, height = 4.85, units = "in", res = 600)
boxplot(phen.disper.spp, xlab = "Species")
dev.off()
TukeyHSD(phen.disper.spp) #Calculate pairwise difference
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = distances ~ group, data = df)
##
## $group
## diff lwr upr p adj
## Populus_tremuloides-Betula_populifolia 0.05929959 0.03449785 0.08410134 9.9e-06
plot(TukeyHSD(phen.disper.spp))
##For GDDs:
# Calculate the multidispersion within data (Calculating significance of
# `Species`)
phen.disper.gdd = betadisper(dist.mat, asv_scaled_noPlants_Phen_filt_LMM$GDD_5C,
type = "centroid")
phen.disper.gdd
##
## Homogeneity of multivariate dispersions
##
## Call: betadisper(d = dist.mat, group =
## asv_scaled_noPlants_Phen_filt_LMM$GDD_5C, type = "centroid")
##
## No. of Positive Eigenvalues: 68
## No. of Negative Eigenvalues: 2
##
## Average distance to centroid:
## 437 605 1087 1606 1992 2140 2219
## 0.6241 0.6066 0.6235 0.6231 0.6219 0.6127 0.6035
##
## Eigenvalues for PCoA axes:
## (Showing 8 of 70 eigenvalues)
## PCoA1 PCoA2 PCoA3 PCoA4 PCoA5 PCoA6 PCoA7 PCoA8
## 3.8467 3.1659 1.3542 1.0663 1.0103 0.9364 0.7918 0.7372
summary(phen.disper.gdd)
## Length Class Mode
## eig 70 -none- numeric
## vectors 4970 -none- numeric
## distances 71 -none- numeric
## group 71 factor numeric
## centroids 490 -none- numeric
## group.distances 7 -none- numeric
## call 4 -none- call
# NOTE: The betadisper function calculates the multivariate dispersion
# (variability) within each group of the categorical variable
# (Growing-Degree-Days-5C).
permutest(phen.disper.gdd, permutations = 10000)
##
## Permutation test for homogeneity of multivariate dispersions
## Permutation: free
## Number of permutations: 10000
##
## Response: Distances
## Df Sum Sq Mean Sq F N.Perm Pr(>F)
## Groups 6 0.00464 0.0007734 0.2441 10000 0.9611
## Residuals 64 0.20274 0.0031678
# NOTE:The permutest function performs a permutation test to assess the
# significance of the F-statistic from the betadisper analysis. The results
# include the number of permutations (N.Perm) performed and the p-value
# (Pr(>F)) associated with the permutation test. In this case, the p-value is
# 0.953, indicating that the F-value is not significant.
anova(phen.disper.gdd)
## Analysis of Variance Table
##
## Response: Distances
## Df Sum Sq Mean Sq F value Pr(>F)
## Groups 6 0.00464 0.0007734 0.2441 0.96
## Residuals 64 0.20274 0.0031678
# The anova function provides an ANOVA-like analysis of the dispersion values
# among the groups. Groups F: The F-statistic for testing the null hypothesis
# of equal dispersion among the groups. The F-value is 0.2429. Groups Pr(>F):
# The p-value associated with the F-statistic. In this case, the p-value is
# 0.9604, indicating that the differences in dispersion among groups are not
# statistically significant.
plot(phen.disper.gdd)
# Save as PNG
png("phen_disper_gdd_pcoa.png", width = 7, height = 4.85, units = "in", res = 600)
plot(phen.disper.gdd)
dev.off()
boxplot(phen.disper.gdd, xlab = "Growing Degree Days")
# Save as PNG
png("phen_disper_gdd_boxplot.png", width = 7, height = 4.85, units = "in", res = 600)
boxplot(phen.disper.gdd, xlab = "Growing Degree Days (5°C)")
dev.off()
TukeyHSD(phen.disper.gdd) #Calculate pairwise difference
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = distances ~ group, data = df)
##
## $group
## diff lwr upr p adj
## 605-437 -0.0174565808 -0.09407792 0.05916476 0.9925249
## 1087-437 -0.0005591488 -0.07541885 0.07430055 1.0000000
## 1606-437 -0.0009830848 -0.07760443 0.07563826 1.0000000
## 1992-437 -0.0021960568 -0.07881740 0.07442529 1.0000000
## 2140-437 -0.0113378561 -0.08795920 0.06528349 0.9993220
## 2219-437 -0.0205512983 -0.09717264 0.05607004 0.9824119
## 1087-605 0.0168974320 -0.05796226 0.09175713 0.9928882
## 1606-605 0.0164734960 -0.06014785 0.09309484 0.9945302
## 1992-605 0.0152605240 -0.06136082 0.09188187 0.9963981
## 2140-605 0.0061187246 -0.07050262 0.08274007 0.9999815
## 2219-605 -0.0030947175 -0.07971606 0.07352662 0.9999997
## 1606-1087 -0.0004239360 -0.07528363 0.07443576 1.0000000
## 1992-1087 -0.0016369080 -0.07649660 0.07322279 1.0000000
## 2140-1087 -0.0107787074 -0.08563840 0.06408099 0.9994202
## 2219-1087 -0.0199921495 -0.09485185 0.05486755 0.9827973
## 1992-1606 -0.0012129720 -0.07783431 0.07540837 1.0000000
## 2140-1606 -0.0103547714 -0.08697611 0.06626657 0.9995973
## 2219-1606 -0.0195682135 -0.09618956 0.05705313 0.9863421
## 2140-1992 -0.0091417994 -0.08576314 0.06747954 0.9998043
## 2219-1992 -0.0183552415 -0.09497658 0.05826610 0.9902357
## 2219-2140 -0.0092134421 -0.08583478 0.06740790 0.9997952
plot(TukeyHSD(phen.disper.gdd))
# Influence taxonomic composition on betadiveristy by Species
phen.spp.adonis2 <- adonis2(dist.mat ~ asv_scaled_noPlants_Phen_filt_LMM$Species,
perm = 10000) #Calculate influence of treatment using community matrix
phen.spp.adonis2
## Permutation test for adonis under reduced model
## Permutation: free
## Number of permutations: 10000
##
## adonis2(formula = dist.mat ~ asv_scaled_noPlants_Phen_filt_LMM$Species, permutations = 10000)
## Df SumOfSqs R2 F Pr(>F)
## Model 1 3.3505 0.10984 8.5143 9.999e-05 ***
## Residual 69 27.1523 0.89016
## Total 70 30.5028 1.00000
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Influence taxonomic composition on betadiveristy by GDDs
phen.gdd.adonis2 <- adonis2(dist.mat ~ asv_scaled_noPlants_Phen_filt_LMM$GDD_5C,
perm = 10000) #Calculate influence of treatment using community matrix
phen.gdd.adonis2
## Permutation test for adonis under reduced model
## Permutation: free
## Number of permutations: 10000
##
## adonis2(formula = dist.mat ~ asv_scaled_noPlants_Phen_filt_LMM$GDD_5C, permutations = 10000)
## Df SumOfSqs R2 F Pr(>F)
## Model 1 1.2548 0.04114 2.9602 9.999e-05 ***
## Residual 69 29.2480 0.95886
## Total 70 30.5028 1.00000
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# 1. Multidispersion Analysis for Interaction (Species & GDDs):
# Calculate multidispersion considering interaction
phen.disper.interact <- betadisper(dist.mat, interaction(asv_scaled_noPlants_Phen_filt_LMM$Species,
asv_scaled_noPlants_Phen_filt_LMM$GDD_5C), type = "centroid")
# 2. Permutation Test for Interaction:
permutest(phen.disper.interact, permutations = 10000)
##
## Permutation test for homogeneity of multivariate dispersions
## Permutation: free
## Number of permutations: 10000
##
## Response: Distances
## Df Sum Sq Mean Sq F N.Perm Pr(>F)
## Groups 13 0.28018 0.021552 4.7151 10000 9.999e-05 ***
## Residuals 57 0.26055 0.004571
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# 3. ANOVA-Like Analysis for Interaction:
anova(phen.disper.interact)
## Analysis of Variance Table
##
## Response: Distances
## Df Sum Sq Mean Sq F value Pr(>F)
## Groups 13 0.28018 0.021552 4.7151 1.858e-05 ***
## Residuals 57 0.26055 0.004571
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
plot(phen.disper.interact)
interaction_multivar_boxplot <- boxplot(phen.disper.interact, xlab = "Species x GDD_5C")
interaction_multivar_boxplot
## $stats
## [,1] [,2] [,3] [,4] [,5] [,6] [,7]
## [1,] 0.4676820 0.5459650 0.3510709 0.5695738 0.4136454 0.5476460 0.4421080
## [2,] 0.5066164 0.5742187 0.3597177 0.5699725 0.4318843 0.5626162 0.4435271
## [3,] 0.5883779 0.5770388 0.3796048 0.5762843 0.4398725 0.5767152 0.5170515
## [4,] 0.6002268 0.5961557 0.4332002 0.5963491 0.5735011 0.6219153 0.5322793
## [5,] 0.6380643 0.5970001 0.4332002 0.6200729 0.6525181 0.6578483 0.5623740
## [,8] [,9] [,10] [,11] [,12] [,13] [,14]
## [1,] 0.5838764 0.4207940 0.5737609 0.4446118 0.4286181 0.2930093 0.5468021
## [2,] 0.5866436 0.4364462 0.5737609 0.5104473 0.4338446 0.3185892 0.5488812
## [3,] 0.6083957 0.5247187 0.5783338 0.5357124 0.4537666 0.3606172 0.5705606
## [4,] 0.6176232 0.5414509 0.5957958 0.5615163 0.5406322 0.4553058 0.5928673
## [5,] 0.6200841 0.6622896 0.5957958 0.6264778 0.5954609 0.5173678 0.6571746
##
## $n
## [1] 5 5 5 5 5 6 5 5 5 5 5 5 5 5
##
## $conf
## [,1] [,2] [,3] [,4] [,5] [,6] [,7]
## [1,] 0.5222331 0.5615381 0.3276823 0.5576466 0.3398065 0.5384654 0.4543394
## [2,] 0.6545227 0.5925395 0.4315273 0.5949220 0.5399386 0.6149650 0.5797636
## [,8] [,9] [,10] [,11] [,12] [,13] [,14]
## [1,] 0.5865056 0.4505226 0.5627640 0.4996272 0.3783107 0.2640136 0.5394801
## [2,] 0.6302858 0.5989147 0.5939036 0.5717977 0.5292225 0.4572208 0.6016411
##
## $out
## 15 26 36
## 0.5991564 0.6399734 0.5181823
##
## $group
## [1] 3 10 10
##
## $names
## [1] "Betula_populifolia.437" "Populus_tremuloides.437"
## [3] "Betula_populifolia.605" "Populus_tremuloides.605"
## [5] "Betula_populifolia.1087" "Populus_tremuloides.1087"
## [7] "Betula_populifolia.1606" "Populus_tremuloides.1606"
## [9] "Betula_populifolia.1992" "Populus_tremuloides.1992"
## [11] "Betula_populifolia.2140" "Populus_tremuloides.2140"
## [13] "Betula_populifolia.2219" "Populus_tremuloides.2219"
# Save the plot to a PNG file
interaction_multivar <- "interaction_multivar_boxplot.jpg"
dev.copy(jpeg, file = interaction_multivar)
## jpeg
## 3
dev.off()
## png
## 2
# Save as PNG
png("interaction_disper_boxplot.png", width = 7, height = 4.85, units = "in", res = 600)
boxplot(phen.disper.interact, xlab = "Species x GDD_5C")
dev.off()
# Post-hoc Pairwise Comparisons for Interaction
pairwise_dispersion_interact <- TukeyHSD(phen.disper.interact)
head(pairwise_dispersion_interact)
## $group
## diff lwr
## Populus_tremuloides.437-Betula_populifolia.437 0.017882185 -0.131869619
## Betula_populifolia.605-Betula_populifolia.437 -0.135643479 -0.285395283
## Populus_tremuloides.605-Betula_populifolia.437 0.026257037 -0.123494767
## Betula_populifolia.1087-Betula_populifolia.437 -0.057909195 -0.207660999
## Populus_tremuloides.1087-Betula_populifolia.437 0.030382548 -0.112993889
## Betula_populifolia.1606-Betula_populifolia.437 -0.060725483 -0.210477287
## Populus_tremuloides.1606-Betula_populifolia.437 0.043131136 -0.106620668
## Betula_populifolia.1992-Betula_populifolia.437 -0.043053596 -0.192805400
## Populus_tremuloides.1992-Betula_populifolia.437 0.021015757 -0.128736047
## Betula_populifolia.2140-Betula_populifolia.437 -0.024440362 -0.174192166
## Populus_tremuloides.2140-Betula_populifolia.437 -0.069728989 -0.219480793
## Betula_populifolia.2219-Betula_populifolia.437 -0.171215614 -0.320967418
## Populus_tremuloides.2219-Betula_populifolia.437 0.023063667 -0.126688137
## Betula_populifolia.605-Populus_tremuloides.437 -0.153525664 -0.303277468
## Populus_tremuloides.605-Populus_tremuloides.437 0.008374851 -0.141376953
## Betula_populifolia.1087-Populus_tremuloides.437 -0.075791380 -0.225543184
## Populus_tremuloides.1087-Populus_tremuloides.437 0.012500363 -0.130876074
## Betula_populifolia.1606-Populus_tremuloides.437 -0.078607668 -0.228359472
## Populus_tremuloides.1606-Populus_tremuloides.437 0.025248951 -0.124502853
## Betula_populifolia.1992-Populus_tremuloides.437 -0.060935781 -0.210687585
## Populus_tremuloides.1992-Populus_tremuloides.437 0.003133571 -0.146618232
## Betula_populifolia.2140-Populus_tremuloides.437 -0.042322547 -0.192074351
## Populus_tremuloides.2140-Populus_tremuloides.437 -0.087611174 -0.237362978
## Betula_populifolia.2219-Populus_tremuloides.437 -0.189097799 -0.338849603
## Populus_tremuloides.2219-Populus_tremuloides.437 0.005181482 -0.144570322
## Populus_tremuloides.605-Betula_populifolia.605 0.161900516 0.012148712
## Betula_populifolia.1087-Betula_populifolia.605 0.077734284 -0.072017520
## Populus_tremuloides.1087-Betula_populifolia.605 0.166026027 0.022649590
## Betula_populifolia.1606-Betula_populifolia.605 0.074917996 -0.074833808
## Populus_tremuloides.1606-Betula_populifolia.605 0.178774615 0.029022811
## Betula_populifolia.1992-Betula_populifolia.605 0.092589883 -0.057161921
## Populus_tremuloides.1992-Betula_populifolia.605 0.156659236 0.006907432
## Betula_populifolia.2140-Betula_populifolia.605 0.111203117 -0.038548687
## Populus_tremuloides.2140-Betula_populifolia.605 0.065914490 -0.083837314
## Betula_populifolia.2219-Betula_populifolia.605 -0.035572135 -0.185323939
## Populus_tremuloides.2219-Betula_populifolia.605 0.158707146 0.008955343
## Betula_populifolia.1087-Populus_tremuloides.605 -0.084166232 -0.233918035
## Populus_tremuloides.1087-Populus_tremuloides.605 0.004125511 -0.139250925
## Betula_populifolia.1606-Populus_tremuloides.605 -0.086982520 -0.236734324
## Populus_tremuloides.1606-Populus_tremuloides.605 0.016874099 -0.132877705
## Betula_populifolia.1992-Populus_tremuloides.605 -0.069310632 -0.219062436
## Populus_tremuloides.1992-Populus_tremuloides.605 -0.005241280 -0.154993084
## Betula_populifolia.2140-Populus_tremuloides.605 -0.050697398 -0.200449202
## Populus_tremuloides.2140-Populus_tremuloides.605 -0.095986025 -0.245737829
## Betula_populifolia.2219-Populus_tremuloides.605 -0.197472651 -0.347224455
## Populus_tremuloides.2219-Populus_tremuloides.605 -0.003193369 -0.152945173
## Populus_tremuloides.1087-Betula_populifolia.1087 0.088291743 -0.055084694
## Betula_populifolia.1606-Betula_populifolia.1087 -0.002816288 -0.152568092
## Populus_tremuloides.1606-Betula_populifolia.1087 0.101040331 -0.048711473
## Betula_populifolia.1992-Betula_populifolia.1087 0.014855599 -0.134896205
## Populus_tremuloides.1992-Betula_populifolia.1087 0.078924952 -0.070826852
## Betula_populifolia.2140-Betula_populifolia.1087 0.033468833 -0.116282971
## Populus_tremuloides.2140-Betula_populifolia.1087 -0.011819794 -0.161571598
## Betula_populifolia.2219-Betula_populifolia.1087 -0.113306419 -0.263058223
## Populus_tremuloides.2219-Betula_populifolia.1087 0.080972862 -0.068778942
## Betula_populifolia.1606-Populus_tremuloides.1087 -0.091108031 -0.234484467
## Populus_tremuloides.1606-Populus_tremuloides.1087 0.012748588 -0.130627848
## Betula_populifolia.1992-Populus_tremuloides.1087 -0.073436144 -0.216812580
## Populus_tremuloides.1992-Populus_tremuloides.1087 -0.009366791 -0.152743228
## Betula_populifolia.2140-Populus_tremuloides.1087 -0.054822910 -0.198199346
## Populus_tremuloides.2140-Populus_tremuloides.1087 -0.100111537 -0.243487973
## Betula_populifolia.2219-Populus_tremuloides.1087 -0.201598162 -0.344974598
## Populus_tremuloides.2219-Populus_tremuloides.1087 -0.007318881 -0.150695317
## Populus_tremuloides.1606-Betula_populifolia.1606 0.103856619 -0.045895185
## Betula_populifolia.1992-Betula_populifolia.1606 0.017671887 -0.132079917
## Populus_tremuloides.1992-Betula_populifolia.1606 0.081741240 -0.068010564
## Betula_populifolia.2140-Betula_populifolia.1606 0.036285121 -0.113466683
## Populus_tremuloides.2140-Betula_populifolia.1606 -0.009003506 -0.158755310
## Betula_populifolia.2219-Betula_populifolia.1606 -0.110490131 -0.260241935
## Populus_tremuloides.2219-Betula_populifolia.1606 0.083789150 -0.065962654
## Betula_populifolia.1992-Populus_tremuloides.1606 -0.086184732 -0.235936536
## Populus_tremuloides.1992-Populus_tremuloides.1606 -0.022115379 -0.171867183
## Betula_populifolia.2140-Populus_tremuloides.1606 -0.067571498 -0.217323302
## Populus_tremuloides.2140-Populus_tremuloides.1606 -0.112860125 -0.262611929
## Betula_populifolia.2219-Populus_tremuloides.1606 -0.214346750 -0.364098554
## Populus_tremuloides.2219-Populus_tremuloides.1606 -0.020067469 -0.169819272
## Populus_tremuloides.1992-Betula_populifolia.1992 0.064069353 -0.085682451
## Betula_populifolia.2140-Betula_populifolia.1992 0.018613234 -0.131138570
## Populus_tremuloides.2140-Betula_populifolia.1992 -0.026675393 -0.176427197
## Betula_populifolia.2219-Betula_populifolia.1992 -0.128162018 -0.277913822
## Populus_tremuloides.2219-Betula_populifolia.1992 0.066117263 -0.083634541
## Betula_populifolia.2140-Populus_tremuloides.1992 -0.045456119 -0.195207922
## Populus_tremuloides.2140-Populus_tremuloides.1992 -0.090744745 -0.240496549
## Betula_populifolia.2219-Populus_tremuloides.1992 -0.192231371 -0.341983175
## Populus_tremuloides.2219-Populus_tremuloides.1992 0.002047911 -0.147703893
## Populus_tremuloides.2140-Betula_populifolia.2140 -0.045288627 -0.195040431
## Betula_populifolia.2219-Betula_populifolia.2140 -0.146775252 -0.296527056
## Populus_tremuloides.2219-Betula_populifolia.2140 0.047504029 -0.102247775
## Betula_populifolia.2219-Populus_tremuloides.2140 -0.101486625 -0.251238429
## Populus_tremuloides.2219-Populus_tremuloides.2140 0.092792656 -0.056959148
## Populus_tremuloides.2219-Betula_populifolia.2219 0.194279281 0.044527478
## upr p adj
## Populus_tremuloides.437-Betula_populifolia.437 0.167633989 0.9999999637
## Betula_populifolia.605-Betula_populifolia.437 0.014108325 0.1143155512
## Populus_tremuloides.605-Betula_populifolia.437 0.176008840 0.9999960185
## Betula_populifolia.1087-Betula_populifolia.437 0.091842609 0.9834402101
## Populus_tremuloides.1087-Betula_populifolia.437 0.173758984 0.9999635957
## Betula_populifolia.1606-Betula_populifolia.437 0.089026321 0.9754412668
## Populus_tremuloides.1606-Betula_populifolia.437 0.192882940 0.9989696682
## Betula_populifolia.1992-Betula_populifolia.437 0.106698208 0.9989885161
## Populus_tremuloides.1992-Betula_populifolia.437 0.170767561 0.9999997314
## Betula_populifolia.2140-Betula_populifolia.437 0.125311442 0.9999983130
## Populus_tremuloides.2140-Betula_populifolia.437 0.080022815 0.9301586549
## Betula_populifolia.2219-Betula_populifolia.437 -0.021463810 0.0119633747
## Populus_tremuloides.2219-Betula_populifolia.437 0.172815471 0.9999991634
## Betula_populifolia.605-Populus_tremuloides.437 -0.003773860 0.0394241694
## Populus_tremuloides.605-Populus_tremuloides.437 0.158126655 1.0000000000
## Betula_populifolia.1087-Populus_tremuloides.437 0.073960424 0.8789438482
## Populus_tremuloides.1087-Populus_tremuloides.437 0.155876799 0.9999999993
## Betula_populifolia.1606-Populus_tremuloides.437 0.071144136 0.8490993570
## Populus_tremuloides.1606-Populus_tremuloides.437 0.175000755 0.9999975057
## Betula_populifolia.1992-Populus_tremuloides.437 0.088816023 0.9747433281
## Populus_tremuloides.1992-Populus_tremuloides.437 0.152885375 1.0000000000
## Betula_populifolia.2140-Populus_tremuloides.437 0.107429257 0.9991521722
## Populus_tremuloides.2140-Populus_tremuloides.437 0.062140630 0.7308665764
## Betula_populifolia.2219-Populus_tremuloides.437 -0.039345995 0.0032114375
## Populus_tremuloides.2219-Populus_tremuloides.437 0.154933286 1.0000000000
## Populus_tremuloides.605-Betula_populifolia.605 0.311652320 0.0227609506
## Betula_populifolia.1087-Betula_populifolia.605 0.227486088 0.8587565363
## Populus_tremuloides.1087-Betula_populifolia.605 0.309402463 0.0102363660
## Betula_populifolia.1606-Betula_populifolia.605 0.224669800 0.8874256864
## Populus_tremuloides.1606-Betula_populifolia.605 0.328526419 0.0069434671
## Betula_populifolia.1992-Betula_populifolia.605 0.242341687 0.6544695011
## Populus_tremuloides.1992-Betula_populifolia.605 0.306411040 0.0322097754
## Betula_populifolia.2140-Betula_populifolia.605 0.260954921 0.3630001799
## Populus_tremuloides.2140-Betula_populifolia.605 0.215666294 0.9534689773
## Betula_populifolia.2219-Betula_populifolia.605 0.114179669 0.9998684033
## Populus_tremuloides.2219-Betula_populifolia.605 0.308458950 0.0281608815
## Betula_populifolia.1087-Populus_tremuloides.605 0.065585572 0.7797643648
## Populus_tremuloides.1087-Populus_tremuloides.605 0.147501948 1.0000000000
## Betula_populifolia.1606-Populus_tremuloides.605 0.062769284 0.7400746653
## Populus_tremuloides.1606-Populus_tremuloides.605 0.166625903 0.9999999824
## Betula_populifolia.1992-Populus_tremuloides.605 0.080441171 0.9330399006
## Populus_tremuloides.1992-Populus_tremuloides.605 0.144510524 1.0000000000
## Betula_populifolia.2140-Populus_tremuloides.605 0.099054405 0.9949537190
## Populus_tremuloides.2140-Populus_tremuloides.605 0.053765779 0.6000169226
## Betula_populifolia.2219-Populus_tremuloides.605 -0.047720847 0.0016823692
## Populus_tremuloides.2219-Populus_tremuloides.605 0.146558435 1.0000000000
## Populus_tremuloides.1087-Betula_populifolia.1087 0.231668179 0.6603521289
## Betula_populifolia.1606-Betula_populifolia.1087 0.146935516 1.0000000000
## Populus_tremuloides.1606-Betula_populifolia.1087 0.250792135 0.5181928008
## Betula_populifolia.1992-Betula_populifolia.1087 0.164607403 0.9999999965
## Populus_tremuloides.1992-Betula_populifolia.1087 0.228676756 0.8455034280
## Betula_populifolia.2140-Betula_populifolia.1087 0.183220637 0.9999333746
## Populus_tremuloides.2140-Betula_populifolia.1087 0.137932010 0.9999999998
## Betula_populifolia.2219-Betula_populifolia.1087 0.036445385 0.3339282217
## Populus_tremuloides.2219-Betula_populifolia.1087 0.230724666 0.8212006488
## Betula_populifolia.1606-Populus_tremuloides.1087 0.052268406 0.6133713789
## Populus_tremuloides.1606-Populus_tremuloides.1087 0.156125025 0.9999999991
## Betula_populifolia.1992-Populus_tremuloides.1087 0.069940293 0.8697118677
## Populus_tremuloides.1992-Populus_tremuloides.1087 0.134009645 1.0000000000
## Betula_populifolia.2140-Populus_tremuloides.1087 0.088553527 0.9849546995
## Populus_tremuloides.2140-Populus_tremuloides.1087 0.043264900 0.4622294917
## Betula_populifolia.2219-Populus_tremuloides.1087 -0.058221725 0.0005930960
## Populus_tremuloides.2219-Populus_tremuloides.1087 0.136057556 1.0000000000
## Populus_tremuloides.1606-Betula_populifolia.1606 0.253608423 0.4733180157
## Betula_populifolia.1992-Betula_populifolia.1606 0.167423691 0.9999999686
## Populus_tremuloides.1992-Betula_populifolia.1606 0.231493044 0.8116098566
## Betula_populifolia.2140-Betula_populifolia.1606 0.186036925 0.9998362114
## Populus_tremuloides.2140-Betula_populifolia.1606 0.140748298 1.0000000000
## Betula_populifolia.2219-Betula_populifolia.1606 0.039261673 0.3731412369
## Populus_tremuloides.2219-Betula_populifolia.1606 0.233540954 0.7848666479
## Betula_populifolia.1992-Populus_tremuloides.1606 0.063567072 0.7515863080
## Populus_tremuloides.1992-Populus_tremuloides.1606 0.127636425 0.9999994983
## Betula_populifolia.2140-Populus_tremuloides.1606 0.082180306 0.9441481219
## Populus_tremuloides.2140-Populus_tremuloides.1606 0.036891679 0.3399881764
## Betula_populifolia.2219-Populus_tremuloides.1606 -0.064594946 0.0004359496
## Populus_tremuloides.2219-Populus_tremuloides.1606 0.129684335 0.9999998479
## Populus_tremuloides.1992-Betula_populifolia.1992 0.213821156 0.9624756244
## Betula_populifolia.2140-Betula_populifolia.1992 0.168365038 0.9999999401
## Populus_tremuloides.2140-Betula_populifolia.1992 0.123076411 0.9999951954
## Betula_populifolia.2219-Betula_populifolia.1992 0.021589786 0.1695887344
## Populus_tremuloides.2219-Betula_populifolia.1992 0.215869067 0.9523924922
## Betula_populifolia.2140-Populus_tremuloides.1992 0.104295685 0.9982467583
## Populus_tremuloides.2140-Populus_tremuloides.1992 0.059007058 0.6834022994
## Betula_populifolia.2219-Populus_tremuloides.1992 -0.042479567 0.0025265890
## Populus_tremuloides.2219-Populus_tremuloides.1992 0.151799715 1.0000000000
## Populus_tremuloides.2140-Betula_populifolia.2140 0.104463177 0.9983103001
## Betula_populifolia.2219-Betula_populifolia.2140 0.002976552 0.0600279755
## Populus_tremuloides.2219-Betula_populifolia.2140 0.197255833 0.9972912200
## Betula_populifolia.2219-Populus_tremuloides.2140 0.048265179 0.5110226209
## Populus_tremuloides.2219-Populus_tremuloides.2140 0.242544460 0.6512555546
## Populus_tremuloides.2219-Betula_populifolia.2219 0.344031085 0.0021571144
# Perform PERMANOVA with interaction term
permanova_beta1 <- adonis2(dist.mat ~ Species + GDD_5C + Species:GDD_5C, data = asv_scaled_noPlants_Phen_filt_LMM,
permutations = 10000, by = "terms")
# Print the PERMANOVA results
print(permanova_beta1)
## Permutation test for adonis under reduced model
## Terms added sequentially (first to last)
## Permutation: free
## Number of permutations: 10000
##
## adonis2(formula = dist.mat ~ Species + GDD_5C + Species:GDD_5C, data = asv_scaled_noPlants_Phen_filt_LMM, permutations = 10000, by = "terms")
## Df SumOfSqs R2 F Pr(>F)
## Species 1 3.3505 0.10984 9.0583 9.999e-05 ***
## GDD_5C 1 1.2520 0.04105 3.3849 9.999e-05 ***
## Species:GDD_5C 1 1.1182 0.03666 3.0232 9.999e-05 ***
## Residual 67 24.7821 0.81245
## Total 70 30.5028 1.00000
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Perform PERMANOVA with interaction term
permanova_beta <- adonis2(dist.mat ~ Species * GDD_5C, data = asv_scaled_noPlants_Phen_filt_LMM,
permutations = 10000, by = "terms")
# Print the PERMANOVA results
print(permanova_beta)
## Permutation test for adonis under reduced model
## Terms added sequentially (first to last)
## Permutation: free
## Number of permutations: 10000
##
## adonis2(formula = dist.mat ~ Species * GDD_5C, data = asv_scaled_noPlants_Phen_filt_LMM, permutations = 10000, by = "terms")
## Df SumOfSqs R2 F Pr(>F)
## Species 1 3.3505 0.10984 9.0583 9.999e-05 ***
## GDD_5C 1 1.2520 0.04105 3.3849 9.999e-05 ***
## Species:GDD_5C 1 1.1182 0.03666 3.0232 9.999e-05 ***
## Residual 67 24.7821 0.81245
## Total 70 30.5028 1.00000
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##Spearman Correlations for PCoA Axes:
# Spearman correlation between Axis 1 and GDD_5C
cor_axis1_gdd_spearman <- cor(pcoa.table_phenology_filtered$Axis.1, asv_scaled_noPlants_Phen_filt_LMM$GDD_5C,
method = "spearman")
# Spearman correlation between Axis 2 and GDD_5C
cor_axis2_gdd_spearman <- cor(pcoa.table_phenology_filtered$Axis.2, asv_scaled_noPlants_Phen_filt_LMM$GDD_5C,
method = "spearman")
# Spearman correlation between Axis 2 and GDD_5C
cor_axis3_gdd_spearman <- cor(pcoa.table_phenology_filtered$Axis.3, asv_scaled_noPlants_Phen_filt_LMM$GDD_5C,
method = "spearman")
# Print results
cat("Spearman correlation between Axis 1 and GDD_5C:", cor_axis1_gdd_spearman, "\n")
## Spearman correlation between Axis 1 and GDD_5C: 0.1084329
cat("Spearman correlation between Axis 2 and GDD_5C:", cor_axis2_gdd_spearman, "\n")
## Spearman correlation between Axis 2 and GDD_5C: -0.5277655
cat("Spearman correlation between Axis 3 and GDD_5C:", cor_axis2_gdd_spearman, "\n")
## Spearman correlation between Axis 3 and GDD_5C: -0.5277655
# Spearman correlation test for Axis 1
cor_test_axis1_spearman <- cor.test(pcoa.table_phenology_filtered$Axis.1, asv_scaled_noPlants_Phen_filt_LMM$GDD_5C,
method = "spearman")
## Warning in cor.test.default(pcoa.table_phenology_filtered$Axis.1,
## asv_scaled_noPlants_Phen_filt_LMM$GDD_5C, : Cannot compute exact p-value with
## ties
# Spearman correlation test for Axis 2
cor_test_axis2_spearman <- cor.test(pcoa.table_phenology_filtered$Axis.2, asv_scaled_noPlants_Phen_filt_LMM$GDD_5C,
method = "spearman")
## Warning in cor.test.default(pcoa.table_phenology_filtered$Axis.2,
## asv_scaled_noPlants_Phen_filt_LMM$GDD_5C, : Cannot compute exact p-value with
## ties
# Spearman correlation test for Axis 3
cor_test_axis3_spearman <- cor.test(pcoa.table_phenology_filtered$Axis.3, asv_scaled_noPlants_Phen_filt_LMM$GDD_5C,
method = "spearman")
## Warning in cor.test.default(pcoa.table_phenology_filtered$Axis.3,
## asv_scaled_noPlants_Phen_filt_LMM$GDD_5C, : Cannot compute exact p-value with
## ties
# Print test results
print(cor_test_axis1_spearman)
##
## Spearman's rank correlation rho
##
## data: pcoa.table_phenology_filtered$Axis.1 and asv_scaled_noPlants_Phen_filt_LMM$GDD_5C
## S = 53173, p-value = 0.3681
## alternative hypothesis: true rho is not equal to 0
## sample estimates:
## rho
## 0.1084329
print(cor_test_axis2_spearman)
##
## Spearman's rank correlation rho
##
## data: pcoa.table_phenology_filtered$Axis.2 and asv_scaled_noPlants_Phen_filt_LMM$GDD_5C
## S = 91116, p-value = 2.25e-06
## alternative hypothesis: true rho is not equal to 0
## sample estimates:
## rho
## -0.5277655
print(cor_test_axis3_spearman)
##
## Spearman's rank correlation rho
##
## data: pcoa.table_phenology_filtered$Axis.3 and asv_scaled_noPlants_Phen_filt_LMM$GDD_5C
## S = 45789, p-value = 0.0513
## alternative hypothesis: true rho is not equal to 0
## sample estimates:
## rho
## 0.2322473
##KPSS Test for Axes:
kpss_beta_axis1 <- ur.kpss(pcoa.table_phenology_filtered$Axis.1)
summary(kpss_beta_axis1)
##
## #######################
## # KPSS Unit Root Test #
## #######################
##
## Test is of type: mu with 3 lags.
##
## Value of test-statistic is: 0.1107
##
## Critical value for a significance level of:
## 10pct 5pct 2.5pct 1pct
## critical values 0.347 0.463 0.574 0.739
# Overall, Axis 1 of the INTERSPECIFIC PCoA is STATIONARY!
kpss_beta_axis2 <- ur.kpss(pcoa.table_phenology_filtered$Axis.2)
summary(kpss_beta_axis2)
##
## #######################
## # KPSS Unit Root Test #
## #######################
##
## Test is of type: mu with 3 lags.
##
## Value of test-statistic is: 0.3475
##
## Critical value for a significance level of:
## 10pct 5pct 2.5pct 1pct
## critical values 0.347 0.463 0.574 0.739
# Overall, Axis 2 of the INTERSPECIFIC PCoA is STATIONARY!
######################################################### MAKING PHYLOSEQ
######################################################### OBJECT INTO
######################################################### DATA.FRAME
library(phyloseq)
library(lme4)
# Make `phyloseq` object into data.frame
ps_df <- psmelt(ps_phen_asv_LMM)
## Warning in psmelt(ps_phen_asv_LMM): The sample variables:
## Species
## have been renamed to:
## sample_Species
## to avoid conflicts with taxonomic rank names.
# Calculate relative abundance for each sample
ps_df <- ps_df %>%
group_by(Sample) %>%
mutate(RelativeAbundance = Abundance/sum(Abundance))
# write.csv(ps_df, file='phyloseq_df.csv')
asv_scaled_noPlants_Phen_filt_LMM$`Collection-Month` <- as.factor(asv_scaled_noPlants_Phen_filt_LMM$`Collection-Month`)
# For Betula
lmm_model_betula_specnumber1 <- lmer(specnumber ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID +
(1 | `Collection-Month`), data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species ==
"Betula_populifolia"))
## boundary (singular) fit: see help('isSingular')
summary(lmm_model_betula_specnumber1)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## specnumber ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID + (1 | `Collection-Month`)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia")
##
## REML criterion at convergence: 324.3
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.71785 -0.52392 -0.05169 0.30514 2.21602
##
## Random effects:
## Groups Name Variance Std.Dev.
## Collection-Month (Intercept) 0.0 0.00
## Residual 850.7 29.17
## Number of obs: 35, groups: Collection-Month, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 2.043e+01 2.576e+01 2.500e+01 0.793 0.435
## GDD_5C 1.319e-02 1.616e-02 2.500e+01 0.816 0.422
## Plant_ID8553606 3.127e+01 3.644e+01 2.500e+01 0.858 0.399
## Plant_ID8553762 -1.386e+01 3.644e+01 2.500e+01 -0.380 0.707
## Plant_ID8553879 -1.693e+01 3.644e+01 2.500e+01 -0.465 0.646
## Plant_ID8554325 -4.164e+00 3.644e+01 2.500e+01 -0.114 0.910
## GDD_5C:Plant_ID8553606 -2.856e-04 2.286e-02 2.500e+01 -0.012 0.990
## GDD_5C:Plant_ID8553762 1.884e-02 2.286e-02 2.500e+01 0.824 0.418
## GDD_5C:Plant_ID8553879 2.431e-03 2.286e-02 2.500e+01 0.106 0.916
## GDD_5C:Plant_ID8554325 1.201e-02 2.286e-02 2.500e+01 0.526 0.604
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C P_ID85536 P_ID85537 P_ID85538 P_ID8554
## GDD_5C -0.904
## P_ID8553606 -0.707 0.639
## P_ID8553762 -0.707 0.639 0.500
## P_ID8553879 -0.707 0.639 0.500 0.500
## P_ID8554325 -0.707 0.639 0.500 0.500 0.500
## GDD_5C:P_ID85536 0.639 -0.707 -0.904 -0.452 -0.452 -0.452
## GDD_5C:P_ID85537 0.639 -0.707 -0.452 -0.904 -0.452 -0.452
## GDD_5C:P_ID85538 0.639 -0.707 -0.452 -0.452 -0.904 -0.452
## GDD_5C:P_ID8554 0.639 -0.707 -0.452 -0.452 -0.452 -0.904
## GDD_5C:P_ID85536 GDD_5C:P_ID85537 GDD_5C:P_ID85538
## GDD_5C
## P_ID8553606
## P_ID8553762
## P_ID8553879
## P_ID8554325
## GDD_5C:P_ID85536
## GDD_5C:P_ID85537 0.500
## GDD_5C:P_ID85538 0.500 0.500
## GDD_5C:P_ID8554 0.500 0.500 0.500
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
# For Betula
lmm_model_betula_specnumber2 <- lmer(sqrt(specnumber) ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID +
(1 | `Collection-Month`), data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species ==
"Betula_populifolia"))
## boundary (singular) fit: see help('isSingular')
summary(lmm_model_betula_specnumber2)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: sqrt(specnumber) ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID + (1 |
## `Collection-Month`)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia")
##
## REML criterion at convergence: 186.8
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.74705 -0.50099 -0.06304 0.44413 1.96010
##
## Random effects:
## Groups Name Variance Std.Dev.
## Collection-Month (Intercept) 0.000 0.000
## Residual 3.481 1.866
## Number of obs: 35, groups: Collection-Month, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 4.5948050 1.6481402 25.0000000 2.788 0.00999 **
## GDD_5C 0.0010938 0.0010339 25.0000000 1.058 0.30017
## Plant_ID8553606 2.2771038 2.3308223 25.0000000 0.977 0.33795
## Plant_ID8553762 -0.6425309 2.3308223 25.0000000 -0.276 0.78507
## Plant_ID8553879 -1.9352696 2.3308223 25.0000000 -0.830 0.41423
## Plant_ID8554325 -0.2525531 2.3308223 25.0000000 -0.108 0.91458
## GDD_5C:Plant_ID8553606 -0.0002254 0.0014621 25.0000000 -0.154 0.87870
## GDD_5C:Plant_ID8553762 0.0009190 0.0014621 25.0000000 0.629 0.53536
## GDD_5C:Plant_ID8553879 0.0004708 0.0014621 25.0000000 0.322 0.75013
## GDD_5C:Plant_ID8554325 0.0006995 0.0014621 25.0000000 0.478 0.63650
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C P_ID85536 P_ID85537 P_ID85538 P_ID8554
## GDD_5C -0.904
## P_ID8553606 -0.707 0.639
## P_ID8553762 -0.707 0.639 0.500
## P_ID8553879 -0.707 0.639 0.500 0.500
## P_ID8554325 -0.707 0.639 0.500 0.500 0.500
## GDD_5C:P_ID85536 0.639 -0.707 -0.904 -0.452 -0.452 -0.452
## GDD_5C:P_ID85537 0.639 -0.707 -0.452 -0.904 -0.452 -0.452
## GDD_5C:P_ID85538 0.639 -0.707 -0.452 -0.452 -0.904 -0.452
## GDD_5C:P_ID8554 0.639 -0.707 -0.452 -0.452 -0.452 -0.904
## GDD_5C:P_ID85536 GDD_5C:P_ID85537 GDD_5C:P_ID85538
## GDD_5C
## P_ID8553606
## P_ID8553762
## P_ID8553879
## P_ID8554325
## GDD_5C:P_ID85536
## GDD_5C:P_ID85537 0.500
## GDD_5C:P_ID85538 0.500 0.500
## GDD_5C:P_ID8554 0.500 0.500 0.500
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
# For Betula
lmm_model_betula_specnumber3 <- lmer(log(specnumber) ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID +
(1 | `Collection-Month`), data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species ==
"Betula_populifolia"))
## boundary (singular) fit: see help('isSingular')
summary(lmm_model_betula_specnumber3)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: log(specnumber) ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID + (1 |
## `Collection-Month`)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia")
##
## REML criterion at convergence: 122.7
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.72648 -0.52026 0.01976 0.58602 1.68132
##
## Random effects:
## Groups Name Variance Std.Dev.
## Collection-Month (Intercept) 0.0000 0.0000
## Residual 0.2681 0.5177
## Number of obs: 35, groups: Collection-Month, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 3.0666427 0.4573402 25.0000000 6.705 5.01e-07 ***
## GDD_5C 0.0003719 0.0002869 25.0000000 1.296 0.207
## Plant_ID8553606 0.6864260 0.6467768 25.0000000 1.061 0.299
## Plant_ID8553762 -0.0811823 0.6467768 25.0000000 -0.126 0.901
## Plant_ID8553879 -0.8984352 0.6467768 25.0000000 -1.389 0.177
## Plant_ID8554325 -0.0565329 0.6467768 25.0000000 -0.087 0.931
## GDD_5C:Plant_ID8553606 -0.0001189 0.0004057 25.0000000 -0.293 0.772
## GDD_5C:Plant_ID8553762 0.0001549 0.0004057 25.0000000 0.382 0.706
## GDD_5C:Plant_ID8553879 0.0002830 0.0004057 25.0000000 0.698 0.492
## GDD_5C:Plant_ID8554325 0.0001586 0.0004057 25.0000000 0.391 0.699
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C P_ID85536 P_ID85537 P_ID85538 P_ID8554
## GDD_5C -0.904
## P_ID8553606 -0.707 0.639
## P_ID8553762 -0.707 0.639 0.500
## P_ID8553879 -0.707 0.639 0.500 0.500
## P_ID8554325 -0.707 0.639 0.500 0.500 0.500
## GDD_5C:P_ID85536 0.639 -0.707 -0.904 -0.452 -0.452 -0.452
## GDD_5C:P_ID85537 0.639 -0.707 -0.452 -0.904 -0.452 -0.452
## GDD_5C:P_ID85538 0.639 -0.707 -0.452 -0.452 -0.904 -0.452
## GDD_5C:P_ID8554 0.639 -0.707 -0.452 -0.452 -0.452 -0.904
## GDD_5C:P_ID85536 GDD_5C:P_ID85537 GDD_5C:P_ID85538
## GDD_5C
## P_ID8553606
## P_ID8553762
## P_ID8553879
## P_ID8554325
## GDD_5C:P_ID85536
## GDD_5C:P_ID85537 0.500
## GDD_5C:P_ID85538 0.500 0.500
## GDD_5C:P_ID8554 0.500 0.500 0.500
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
# For Betula
lmm_model_betula_specnumber4 <- lmer(I(specnumber^2) ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID +
(1 | `Collection-Month`), data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species ==
"Betula_populifolia"))
## boundary (singular) fit: see help('isSingular')
summary(lmm_model_betula_specnumber4)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: I(specnumber^2) ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID + (1 |
## `Collection-Month`)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia")
##
## REML criterion at convergence: 573.9
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.60437 -0.38163 -0.08494 0.15382 2.65129
##
## Random effects:
## Groups Name Variance Std.Dev.
## Collection-Month (Intercept) 0 0
## Residual 18443574 4295
## Number of obs: 35, groups: Collection-Month, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 276.8371 3793.5837 25.0000 0.073 0.942
## GDD_5C 1.0274 2.3797 25.0000 0.432 0.670
## Plant_ID8553606 3210.3274 5364.9375 25.0000 0.598 0.555
## Plant_ID8553762 -2541.1967 5364.9375 25.0000 -0.474 0.640
## Plant_ID8553879 -658.6225 5364.9375 25.0000 -0.123 0.903
## Plant_ID8554325 -494.9443 5364.9375 25.0000 -0.092 0.927
## GDD_5C:Plant_ID8553606 0.7519 3.3654 25.0000 0.223 0.825
## GDD_5C:Plant_ID8553762 3.5425 3.3654 25.0000 1.053 0.303
## GDD_5C:Plant_ID8553879 -0.1386 3.3654 25.0000 -0.041 0.967
## GDD_5C:Plant_ID8554325 1.7399 3.3654 25.0000 0.517 0.610
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C P_ID85536 P_ID85537 P_ID85538 P_ID8554
## GDD_5C -0.904
## P_ID8553606 -0.707 0.639
## P_ID8553762 -0.707 0.639 0.500
## P_ID8553879 -0.707 0.639 0.500 0.500
## P_ID8554325 -0.707 0.639 0.500 0.500 0.500
## GDD_5C:P_ID85536 0.639 -0.707 -0.904 -0.452 -0.452 -0.452
## GDD_5C:P_ID85537 0.639 -0.707 -0.452 -0.904 -0.452 -0.452
## GDD_5C:P_ID85538 0.639 -0.707 -0.452 -0.452 -0.904 -0.452
## GDD_5C:P_ID8554 0.639 -0.707 -0.452 -0.452 -0.452 -0.904
## GDD_5C:P_ID85536 GDD_5C:P_ID85537 GDD_5C:P_ID85538
## GDD_5C
## P_ID8553606
## P_ID8553762
## P_ID8553879
## P_ID8554325
## GDD_5C:P_ID85536
## GDD_5C:P_ID85537 0.500
## GDD_5C:P_ID85538 0.500 0.500
## GDD_5C:P_ID8554 0.500 0.500 0.500
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
# For Betula
lmm_model_betula_specnumber5 <- lmer((1/specnumber) ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID +
(1 | `Collection-Month`), data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species ==
"Betula_populifolia"))
## boundary (singular) fit: see help('isSingular')
summary(lmm_model_betula_specnumber5)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## (1/specnumber) ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID + (1 | `Collection-Month`)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia")
##
## REML criterion at convergence: -59.6
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.21647 -0.58267 -0.02344 0.59187 2.23604
##
## Random effects:
## Groups Name Variance Std.Dev.
## Collection-Month (Intercept) 0.0000000 0.00000
## Residual 0.0001825 0.01351
## Number of obs: 35, groups: Collection-Month, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 4.617e-02 1.193e-02 2.500e+01 3.869 0.000693 ***
## GDD_5C -1.159e-05 7.486e-06 2.500e+01 -1.548 0.134146
## Plant_ID8553606 -1.753e-02 1.688e-02 2.500e+01 -1.039 0.308790
## Plant_ID8553762 -4.042e-03 1.688e-02 2.500e+01 -0.239 0.812705
## Plant_ID8553879 5.142e-02 1.688e-02 2.500e+01 3.046 0.005400 **
## Plant_ID8554325 3.736e-04 1.688e-02 2.500e+01 0.022 0.982514
## GDD_5C:Plant_ID8553606 5.021e-06 1.059e-05 2.500e+01 0.474 0.639440
## GDD_5C:Plant_ID8553762 1.504e-06 1.059e-05 2.500e+01 0.142 0.888181
## GDD_5C:Plant_ID8553879 -2.090e-05 1.059e-05 2.500e+01 -1.974 0.059512 .
## GDD_5C:Plant_ID8554325 -1.527e-06 1.059e-05 2.500e+01 -0.144 0.886447
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C P_ID85536 P_ID85537 P_ID85538 P_ID8554
## GDD_5C -0.904
## P_ID8553606 -0.707 0.639
## P_ID8553762 -0.707 0.639 0.500
## P_ID8553879 -0.707 0.639 0.500 0.500
## P_ID8554325 -0.707 0.639 0.500 0.500 0.500
## GDD_5C:P_ID85536 0.639 -0.707 -0.904 -0.452 -0.452 -0.452
## GDD_5C:P_ID85537 0.639 -0.707 -0.452 -0.904 -0.452 -0.452
## GDD_5C:P_ID85538 0.639 -0.707 -0.452 -0.452 -0.904 -0.452
## GDD_5C:P_ID8554 0.639 -0.707 -0.452 -0.452 -0.452 -0.904
## GDD_5C:P_ID85536 GDD_5C:P_ID85537 GDD_5C:P_ID85538
## GDD_5C
## P_ID8553606
## P_ID8553762
## P_ID8553879
## P_ID8554325
## GDD_5C:P_ID85536
## GDD_5C:P_ID85537 0.500
## GDD_5C:P_ID85538 0.500 0.500
## GDD_5C:P_ID8554 0.500 0.500 0.500
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
# NOTE: `lmm_model_betula_specnumber3` is most promising, BUT `Plant_ID` and
# `GDD_5C:Plant_ID` have high VIFs. So, let's try dropping `Plant_ID` itself.
lmm_model_betula_specnumber6 <- lmer(log(specnumber) ~ GDD_5C + GDD_5C:Plant_ID +
(1 | `Collection-Month`), data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species ==
"Betula_populifolia"))
## boundary (singular) fit: see help('isSingular')
summary(lmm_model_betula_specnumber6)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: log(specnumber) ~ GDD_5C + GDD_5C:Plant_ID + (1 | `Collection-Month`)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia")
##
## REML criterion at convergence: 131.4
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.66426 -0.61077 -0.01216 0.59837 1.81403
##
## Random effects:
## Groups Name Variance Std.Dev.
## Collection-Month (Intercept) 0.0000 0.0000
## Residual 0.2869 0.5357
## Number of obs: 35, groups: Collection-Month, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 2.9966979 0.2116062 29.0000000 14.162 1.47e-14 ***
## GDD_5C 0.0004116 0.0001747 29.0000000 2.356 0.0255 *
## GDD_5C:Plant_ID8553606 0.0002702 0.0001796 29.0000000 1.505 0.1432
## GDD_5C:Plant_ID8553762 0.0001088 0.0001796 29.0000000 0.606 0.5493
## GDD_5C:Plant_ID8553879 -0.0002263 0.0001796 29.0000000 -1.260 0.2176
## GDD_5C:Plant_ID8554325 0.0001266 0.0001796 29.0000000 0.705 0.4867
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C GDD_5C:P_ID85536 GDD_5C:P_ID85537
## GDD_5C -0.687
## GDD_5C:P_ID85536 0.000 -0.514
## GDD_5C:P_ID85537 0.000 -0.514 0.500
## GDD_5C:P_ID85538 0.000 -0.514 0.500 0.500
## GDD_5C:P_ID8554 0.000 -0.514 0.500 0.500
## GDD_5C:P_ID85538
## GDD_5C
## GDD_5C:P_ID85536
## GDD_5C:P_ID85537
## GDD_5C:P_ID85538
## GDD_5C:P_ID8554 0.500
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
# Another time by dropping the interaction term
lmm_model_betula_specnumber7 <- lmer(log(specnumber) ~ GDD_5C + Plant_ID + (1 | `Collection-Month`),
data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia"))
## boundary (singular) fit: see help('isSingular')
summary(lmm_model_betula_specnumber7)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: log(specnumber) ~ GDD_5C + Plant_ID + (1 | `Collection-Month`)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia")
##
## REML criterion at convergence: 67.5
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.73249 -0.62976 -0.07621 0.64473 1.83577
##
## Random effects:
## Groups Name Variance Std.Dev.
## Collection-Month (Intercept) 0.0000 0.000
## Residual 0.2421 0.492
## Number of obs: 35, groups: Collection-Month, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 2.9290205 0.2558128 29.0000000 11.450 2.81e-12 ***
## GDD_5C 0.0004674 0.0001219 29.0000000 3.834 0.000627 ***
## Plant_ID8553606 0.5150627 0.2629848 29.0000000 1.959 0.059848 .
## Plant_ID8553762 0.1419428 0.2629848 29.0000000 0.540 0.593498
## Plant_ID8553879 -0.4906177 0.2629848 29.0000000 -1.866 0.072247 .
## Plant_ID8554325 0.1719989 0.2629848 29.0000000 0.654 0.518248
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C P_ID85536 P_ID85537 P_ID85538
## GDD_5C -0.687
## P_ID8553606 -0.514 0.000
## P_ID8553762 -0.514 0.000 0.500
## P_ID8553879 -0.514 0.000 0.500 0.500
## P_ID8554325 -0.514 0.000 0.500 0.500 0.500
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
# One more time with ONLY GDD_5C as fixed; `Collection-Month` as random
lmm_model_betula_specnumber8 <- lmer(log(specnumber) ~ GDD_5C + (1 | `Collection-Month`),
data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia"))
## boundary (singular) fit: see help('isSingular')
summary(lmm_model_betula_specnumber8)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: log(specnumber) ~ GDD_5C + (1 | `Collection-Month`)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia")
##
## REML criterion at convergence: 76.8
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.5740 -0.7549 -0.1469 0.6104 2.1108
##
## Random effects:
## Groups Name Variance Std.Dev.
## Collection-Month (Intercept) 0.0000 0.0000
## Residual 0.3257 0.5707
## Number of obs: 35, groups: Collection-Month, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 2.997e+00 2.255e-01 3.300e+01 13.291 8.41e-15 ***
## GDD_5C 4.674e-04 1.414e-04 3.300e+01 3.305 0.0023 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## GDD_5C -0.904
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
# And one last time with ONLY GDD_5C as fixed; `Plant_ID` as random
lmm_model_betula_specnumber9 <- lmer(log(specnumber) ~ GDD_5C + (1 | Plant_ID), data = subset(asv_scaled_noPlants_Phen_filt_LMM,
Species == "Betula_populifolia"))
summary(lmm_model_betula_specnumber9)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: log(specnumber) ~ GDD_5C + (1 | Plant_ID)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia")
##
## REML criterion at convergence: 72.4
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.6933 -0.6163 -0.1776 0.6529 1.8749
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0.09863 0.314
## Residual 0.24206 0.492
## Number of obs: 35, groups: Plant_ID, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 2.997e+00 2.398e-01 1.572e+01 12.497 1.41e-09 ***
## GDD_5C 4.674e-04 1.219e-04 2.900e+01 3.834 0.000627 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## GDD_5C -0.733
# Wait! The 1/x transformation has a very low AIC and BIC; let's try altering
# it.
lmm_model_betula_specnumber10 <- lmer((1/specnumber) ~ GDD_5C + (1 | Plant_ID), data = subset(asv_scaled_noPlants_Phen_filt_LMM,
Species == "Betula_populifolia"))
summary(lmm_model_betula_specnumber10)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: (1/specnumber) ~ GDD_5C + (1 | Plant_ID)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia")
##
## REML criterion at convergence: -160.3
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.48626 -0.50298 -0.03675 0.52908 2.69893
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0.0001099 0.01048
## Residual 0.0002041 0.01429
## Number of obs: 35, groups: Plant_ID, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 5.222e-02 7.336e-03 1.337e+01 7.118 6.7e-06 ***
## GDD_5C -1.477e-05 3.540e-06 2.900e+01 -4.172 0.00025 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## GDD_5C -0.695
lmm_model_betula_specnumber11 <- lmer((1/specnumber) ~ GDD_5C + (1 | `Collection-Month`),
data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia"))
## boundary (singular) fit: see help('isSingular')
summary(lmm_model_betula_specnumber11)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: (1/specnumber) ~ GDD_5C + (1 | `Collection-Month`)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia")
##
## REML criterion at convergence: -154.2
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.7479 -0.6156 -0.1100 0.4882 3.1456
##
## Random effects:
## Groups Name Variance Std.Dev.
## Collection-Month (Intercept) 0.0000000 0.00000
## Residual 0.0002973 0.01724
## Number of obs: 35, groups: Collection-Month, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 5.222e-02 6.811e-03 3.300e+01 7.666 7.95e-09 ***
## GDD_5C -1.477e-05 4.273e-06 3.300e+01 -3.457 0.00152 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## GDD_5C -0.904
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
lmm_model_betula_specnumber12 <- lmer(specnumber ~ GDD_5C + GDD_5C:Plant_ID + (1 |
Plant_ID), data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia"))
## boundary (singular) fit: see help('isSingular')
summary(lmm_model_betula_specnumber12)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: specnumber ~ GDD_5C + GDD_5C:Plant_ID + (1 | Plant_ID)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia")
##
## REML criterion at convergence: 361.4
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.6742 -0.5280 -0.1407 0.5102 2.3476
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0.0 0.00
## Residual 798.4 28.26
## Number of obs: 35, groups: Plant_ID, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 19.688808 11.162183 29.000000 1.764 0.0883 .
## GDD_5C 0.013606 0.009216 29.000000 1.476 0.1506
## GDD_5C:Plant_ID8553606 0.017443 0.009474 29.000000 1.841 0.0759 .
## GDD_5C:Plant_ID8553762 0.010981 0.009474 29.000000 1.159 0.2559
## GDD_5C:Plant_ID8553879 -0.007168 0.009474 29.000000 -0.757 0.4554
## GDD_5C:Plant_ID8554325 0.009651 0.009474 29.000000 1.019 0.3168
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C GDD_5C:P_ID85536 GDD_5C:P_ID85537
## GDD_5C -0.687
## GDD_5C:P_ID85536 0.000 -0.514
## GDD_5C:P_ID85537 0.000 -0.514 0.500
## GDD_5C:P_ID85538 0.000 -0.514 0.500 0.500
## GDD_5C:P_ID8554 0.000 -0.514 0.500 0.500
## GDD_5C:P_ID85538
## GDD_5C
## GDD_5C:P_ID85536
## GDD_5C:P_ID85537
## GDD_5C:P_ID85538
## GDD_5C:P_ID8554 0.500
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
lmm_model_betula_specnumber13 <- lmer(log(specnumber) ~ GDD_5C + GDD_5C:Plant_ID +
(1 | Plant_ID), data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia"))
summary(lmm_model_betula_specnumber13)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: log(specnumber) ~ GDD_5C + GDD_5C:Plant_ID + (1 | Plant_ID)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia")
##
## REML criterion at convergence: 131.1
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.7234 -0.6582 -0.1453 0.6211 1.6874
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0.1068 0.3267
## Residual 0.2681 0.5177
## Number of obs: 35, groups: Plant_ID, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 2.9966978 0.2513654 4.0000000 11.922 0.000284 ***
## GDD_5C 0.0003982 0.0002161 6.7718832 1.843 0.109348
## GDD_5C:Plant_ID8553606 0.0001387 0.0002749 2.8723540 0.505 0.649978
## GDD_5C:Plant_ID8553762 0.0001244 0.0002749 2.8723540 0.452 0.682926
## GDD_5C:Plant_ID8553879 -0.0000542 0.0002749 2.8723540 -0.197 0.856820
## GDD_5C:Plant_ID8554325 0.0001374 0.0002749 2.8723540 0.500 0.653015
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C GDD_5C:P_ID85536 GDD_5C:P_ID85537
## GDD_5C -0.437
## GDD_5C:P_ID85536 0.000 -0.636
## GDD_5C:P_ID85537 0.000 -0.636 0.500
## GDD_5C:P_ID85538 0.000 -0.636 0.500 0.500
## GDD_5C:P_ID8554 0.000 -0.636 0.500 0.500
## GDD_5C:P_ID85538
## GDD_5C
## GDD_5C:P_ID85536
## GDD_5C:P_ID85537
## GDD_5C:P_ID85538
## GDD_5C:P_ID8554 0.500
lmm_model_betula_specnumber14 <- lmer((1/specnumber) ~ GDD_5C + GDD_5C:Plant_ID +
(1 | Plant_ID), data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia"))
summary(lmm_model_betula_specnumber14)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: (1/specnumber) ~ GDD_5C + GDD_5C:Plant_ID + (1 | Plant_ID)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia")
##
## REML criterion at convergence: -75.7
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.27658 -0.55382 -0.05178 0.54787 2.20311
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0.0005538 0.02353
## Residual 0.0001825 0.01351
## Number of obs: 35, groups: Plant_ID, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 5.222e-02 1.180e-02 4.000e+00 4.425 0.0115 *
## GDD_5C -1.229e-05 6.968e-06 2.893e+01 -1.764 0.0883 .
## GDD_5C:Plant_ID8553606 2.987e-06 9.662e-06 2.807e+01 0.309 0.7595
## GDD_5C:Plant_ID8553762 1.035e-06 9.662e-06 2.807e+01 0.107 0.9154
## GDD_5C:Plant_ID8553879 -1.494e-05 9.662e-06 2.807e+01 -1.546 0.1333
## GDD_5C:Plant_ID8554325 -1.484e-06 9.662e-06 2.807e+01 -0.154 0.8790
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C GDD_5C:P_ID85536 GDD_5C:P_ID85537
## GDD_5C -0.196
## GDD_5C:P_ID85536 0.000 -0.693
## GDD_5C:P_ID85537 0.000 -0.693 0.500
## GDD_5C:P_ID85538 0.000 -0.693 0.500 0.500
## GDD_5C:P_ID8554 0.000 -0.693 0.500 0.500
## GDD_5C:P_ID85538
## GDD_5C
## GDD_5C:P_ID85536
## GDD_5C:P_ID85537
## GDD_5C:P_ID85538
## GDD_5C:P_ID8554 0.500
lmm_model_betula_specnumber15 <- lmer(I(specnumber^2) ~ GDD_5C + GDD_5C:Plant_ID +
(1 | Plant_ID), data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia"))
## boundary (singular) fit: see help('isSingular')
summary(lmm_model_betula_specnumber15)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: I(specnumber^2) ~ GDD_5C + GDD_5C:Plant_ID + (1 | Plant_ID)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia")
##
## REML criterion at convergence: 649.9
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.5599 -0.3955 -0.1140 0.1745 2.8664
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0 0
## Residual 16668391 4083
## Number of obs: 35, groups: Plant_ID, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 179.950 1612.831 29.000 0.112 0.9119
## GDD_5C 1.082 1.332 29.000 0.813 0.4230
## GDD_5C:Plant_ID8553606 2.572 1.369 29.000 1.879 0.0703 .
## GDD_5C:Plant_ID8553762 2.102 1.369 29.000 1.535 0.1356
## GDD_5C:Plant_ID8553879 -0.512 1.369 29.000 -0.374 0.7111
## GDD_5C:Plant_ID8554325 1.459 1.369 29.000 1.066 0.2952
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C GDD_5C:P_ID85536 GDD_5C:P_ID85537
## GDD_5C -0.687
## GDD_5C:P_ID85536 0.000 -0.514
## GDD_5C:P_ID85537 0.000 -0.514 0.500
## GDD_5C:P_ID85538 0.000 -0.514 0.500 0.500
## GDD_5C:P_ID8554 0.000 -0.514 0.500 0.500
## GDD_5C:P_ID85538
## GDD_5C
## GDD_5C:P_ID85536
## GDD_5C:P_ID85537
## GDD_5C:P_ID85538
## GDD_5C:P_ID8554 0.500
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
lmm_model_betula_specnumber16 <- lmer(sqrt(specnumber) ~ GDD_5C + GDD_5C:Plant_ID +
(1 | Plant_ID), data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia"))
## boundary (singular) fit: see help('isSingular')
summary(lmm_model_betula_specnumber16)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: sqrt(specnumber) ~ GDD_5C + GDD_5C:Plant_ID + (1 | Plant_ID)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia")
##
## REML criterion at convergence: 203.2
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.7027 -0.6037 -0.1234 0.5940 2.0165
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0.000 0.000
## Residual 3.414 1.848
## Number of obs: 35, groups: Plant_ID, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 4.4841550 0.7299270 29.0000000 6.143 1.08e-06 ***
## GDD_5C 0.0011566 0.0006026 29.0000000 1.919 0.0649 .
## GDD_5C:Plant_ID8553606 0.0010656 0.0006195 29.0000000 1.720 0.0961 .
## GDD_5C:Plant_ID8553762 0.0005547 0.0006195 29.0000000 0.895 0.3780
## GDD_5C:Plant_ID8553879 -0.0006264 0.0006195 29.0000000 -1.011 0.3203
## GDD_5C:Plant_ID8554325 0.0005563 0.0006195 29.0000000 0.898 0.3766
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C GDD_5C:P_ID85536 GDD_5C:P_ID85537
## GDD_5C -0.687
## GDD_5C:P_ID85536 0.000 -0.514
## GDD_5C:P_ID85537 0.000 -0.514 0.500
## GDD_5C:P_ID85538 0.000 -0.514 0.500 0.500
## GDD_5C:P_ID8554 0.000 -0.514 0.500 0.500
## GDD_5C:P_ID85538
## GDD_5C
## GDD_5C:P_ID85536
## GDD_5C:P_ID85537
## GDD_5C:P_ID85538
## GDD_5C:P_ID8554 0.500
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
# For Betula
asv_scaled_noPlants_Phen_filt_LMM$sample_id <- as.factor(asv_scaled_noPlants_Phen_filt_LMM$sample_id)
lmm_model_betula_specnumber17 <- lmer((1/specnumber) ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID +
(1 | Plant_ID), data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia"))
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## unable to evaluate scaled gradient
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## Hessian is numerically singular: parameters are not uniquely determined
## Warning in as_lmerModLT(model, devfun): Model may not have converged with 1
## eigenvalue close to zero: 2.3e-10
summary(lmm_model_betula_specnumber17)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: (1/specnumber) ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID + (1 | Plant_ID)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia")
##
## REML criterion at convergence: -59.6
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.21647 -0.58267 -0.02344 0.59187 2.23604
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0.0004688 0.02165
## Residual 0.0001825 0.01351
## Number of obs: 35, groups: Plant_ID, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 4.617e-02 2.472e-02 2.500e+01 1.868 0.0736 .
## GDD_5C -1.159e-05 7.486e-06 2.500e+01 -1.548 0.1341
## Plant_ID8553606 -1.753e-02 3.496e-02 2.500e+01 -0.501 0.6204
## Plant_ID8553762 -4.042e-03 3.496e-02 2.500e+01 -0.116 0.9089
## Plant_ID8553879 5.142e-02 3.496e-02 2.500e+01 1.471 0.1539
## Plant_ID8554325 3.736e-04 3.496e-02 2.500e+01 0.011 0.9916
## GDD_5C:Plant_ID8553606 5.021e-06 1.059e-05 2.500e+01 0.474 0.6394
## GDD_5C:Plant_ID8553762 1.504e-06 1.059e-05 2.500e+01 0.142 0.8882
## GDD_5C:Plant_ID8553879 -2.090e-05 1.059e-05 2.500e+01 -1.974 0.0595 .
## GDD_5C:Plant_ID8554325 -1.527e-06 1.059e-05 2.500e+01 -0.144 0.8864
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C P_ID85536 P_ID85537 P_ID85538 P_ID8554
## GDD_5C -0.436
## P_ID8553606 -0.707 0.309
## P_ID8553762 -0.707 0.309 0.500
## P_ID8553879 -0.707 0.309 0.500 0.500
## P_ID8554325 -0.707 0.309 0.500 0.500 0.500
## GDD_5C:P_ID85536 0.309 -0.707 -0.436 -0.218 -0.218 -0.218
## GDD_5C:P_ID85537 0.309 -0.707 -0.218 -0.436 -0.218 -0.218
## GDD_5C:P_ID85538 0.309 -0.707 -0.218 -0.218 -0.436 -0.218
## GDD_5C:P_ID8554 0.309 -0.707 -0.218 -0.218 -0.218 -0.436
## GDD_5C:P_ID85536 GDD_5C:P_ID85537 GDD_5C:P_ID85538
## GDD_5C
## P_ID8553606
## P_ID8553762
## P_ID8553879
## P_ID8554325
## GDD_5C:P_ID85536
## GDD_5C:P_ID85537 0.500
## GDD_5C:P_ID85538 0.500 0.500
## GDD_5C:P_ID8554 0.500 0.500 0.500
## optimizer (nloptwrap) convergence code: 0 (OK)
## unable to evaluate scaled gradient
## Hessian is numerically singular: parameters are not uniquely determined
lmm_model_betula_specnumber19 <- lmer((1/specnumber) ~ GDD_5C + Plant_ID + (1 | Plant_ID),
data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia"))
## Warning in as_lmerModLT(model, devfun): Model may not have converged with 1
## eigenvalue close to zero: -1.0e-10
summary(lmm_model_betula_specnumber19)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: (1/specnumber) ~ GDD_5C + Plant_ID + (1 | Plant_ID)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia")
##
## REML criterion at convergence: -137.8
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.77756 -0.51121 -0.04082 0.54414 2.40763
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 8.387e-05 0.009158
## Residual 2.041e-04 0.014286
## Number of obs: 35, groups: Plant_ID, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 5.076e-02 1.179e-02 2.900e+01 4.305 0.000174 ***
## GDD_5C -1.477e-05 3.540e-06 2.900e+01 -4.172 0.000250 ***
## Plant_ID8553606 -1.030e-02 1.504e-02 2.900e+01 -0.685 0.498736
## Plant_ID8553762 -1.875e-03 1.504e-02 2.900e+01 -0.125 0.901636
## Plant_ID8553879 2.130e-02 1.504e-02 2.900e+01 1.417 0.167193
## Plant_ID8554325 -1.827e-03 1.504e-02 2.900e+01 -0.122 0.904113
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C P_ID85536 P_ID85537 P_ID85538
## GDD_5C -0.433
## P_ID8553606 -0.638 0.000
## P_ID8553762 -0.638 0.000 0.500
## P_ID8553879 -0.638 0.000 0.500 0.500
## P_ID8554325 -0.638 0.000 0.500 0.500 0.500
# For Betula
lmm_model_betula_specnumber20 <- lmer(specnumber ~ GDD_5C + Plant_ID + (1 | Plant_ID),
data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia"))
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## unable to evaluate scaled gradient
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## Hessian is numerically singular: parameters are not uniquely determined
## Warning in as_lmerModLT(model, devfun): Model may not have converged with 1
## eigenvalue close to zero: -1.6e-09
summary(lmm_model_betula_specnumber20)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: specnumber ~ GDD_5C + Plant_ID + (1 | Plant_ID)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia")
##
## REML criterion at convergence: 301.2
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.5248 -0.5077 -0.1391 0.4742 2.5796
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 205.7 14.34
## Residual 765.7 27.67
## Number of obs: 35, groups: Plant_ID, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 10.917380 20.315396 29.000000 0.537 0.5951
## GDD_5C 0.019788 0.006857 29.000000 2.886 0.0073 **
## Plant_ID8553606 30.857143 25.103988 29.000000 1.229 0.2289
## Plant_ID8553762 13.285714 25.103988 29.000000 0.529 0.6007
## Plant_ID8553879 -13.428571 25.103988 29.000000 -0.535 0.5968
## Plant_ID8554325 13.142857 25.103988 29.000000 0.524 0.6046
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C P_ID85536 P_ID85537 P_ID85538
## GDD_5C -0.486
## P_ID8553606 -0.618 0.000
## P_ID8553762 -0.618 0.000 0.500
## P_ID8553879 -0.618 0.000 0.500 0.500
## P_ID8554325 -0.618 0.000 0.500 0.500 0.500
## optimizer (nloptwrap) convergence code: 0 (OK)
## unable to evaluate scaled gradient
## Hessian is numerically singular: parameters are not uniquely determined
# For Betula
lmm_model_betula_specnumber21 <- lmer(specnumber ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID +
(1 | Plant_ID), data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia"))
## Warning in as_lmerModLT(model, devfun): Model may not have converged with 1
## eigenvalue close to zero: -1.6e-10
summary(lmm_model_betula_specnumber21)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: specnumber ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID + (1 | Plant_ID)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia")
##
## REML criterion at convergence: 324.3
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.71785 -0.52392 -0.05169 0.30514 2.21602
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 225.2 15.01
## Residual 850.7 29.17
## Number of obs: 35, groups: Plant_ID, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 2.043e+01 2.982e+01 2.500e+01 0.685 0.500
## GDD_5C 1.319e-02 1.616e-02 2.500e+01 0.816 0.422
## Plant_ID8553606 3.127e+01 4.217e+01 2.500e+01 0.742 0.465
## Plant_ID8553762 -1.386e+01 4.217e+01 2.500e+01 -0.329 0.745
## Plant_ID8553879 -1.693e+01 4.217e+01 2.500e+01 -0.402 0.691
## Plant_ID8554325 -4.164e+00 4.217e+01 2.500e+01 -0.099 0.922
## GDD_5C:Plant_ID8553606 -2.856e-04 2.286e-02 2.500e+01 -0.012 0.990
## GDD_5C:Plant_ID8553762 1.884e-02 2.286e-02 2.500e+01 0.824 0.418
## GDD_5C:Plant_ID8553879 2.431e-03 2.286e-02 2.500e+01 0.106 0.916
## GDD_5C:Plant_ID8554325 1.201e-02 2.286e-02 2.500e+01 0.526 0.604
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C P_ID85536 P_ID85537 P_ID85538 P_ID8554
## GDD_5C -0.781
## P_ID8553606 -0.707 0.552
## P_ID8553762 -0.707 0.552 0.500
## P_ID8553879 -0.707 0.552 0.500 0.500
## P_ID8554325 -0.707 0.552 0.500 0.500 0.500
## GDD_5C:P_ID85536 0.552 -0.707 -0.781 -0.391 -0.391 -0.391
## GDD_5C:P_ID85537 0.552 -0.707 -0.391 -0.781 -0.391 -0.391
## GDD_5C:P_ID85538 0.552 -0.707 -0.391 -0.391 -0.781 -0.391
## GDD_5C:P_ID8554 0.552 -0.707 -0.391 -0.391 -0.391 -0.781
## GDD_5C:P_ID85536 GDD_5C:P_ID85537 GDD_5C:P_ID85538
## GDD_5C
## P_ID8553606
## P_ID8553762
## P_ID8553879
## P_ID8554325
## GDD_5C:P_ID85536
## GDD_5C:P_ID85537 0.500
## GDD_5C:P_ID85538 0.500 0.500
## GDD_5C:P_ID8554 0.500 0.500 0.500
# For Betula
lmm_model_betula_specnumber22 <- lmer(specnumber ~ I(GDD_5C^2) + Plant_ID + I(GDD_5C^2):Plant_ID +
(1 | Plant_ID), data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia"))
## Warning: Some predictor variables are on very different scales: consider
## rescaling
## Warning: Some predictor variables are on very different scales: consider
## rescaling
## Warning: Model failed to converge with 1 negative eigenvalue: -6.3e-08
summary(lmm_model_betula_specnumber22)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: specnumber ~ I(GDD_5C^2) + Plant_ID + I(GDD_5C^2):Plant_ID +
## (1 | Plant_ID)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia")
##
## REML criterion at convergence: 403.6
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.78112 -0.40957 -0.08648 0.20882 2.22339
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 14.42 3.797
## Residual 858.66 29.303
## Number of obs: 35, groups: Plant_ID, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 2.665e+01 1.919e+01 2.500e+01 1.388 0.177
## I(GDD_5C^2) 5.028e-06 5.985e-06 2.500e+01 0.840 0.409
## Plant_ID8553606 3.365e+01 2.714e+01 2.500e+01 1.240 0.227
## Plant_ID8553762 -4.456e+00 2.714e+01 2.500e+01 -0.164 0.871
## Plant_ID8553879 -1.521e+01 2.714e+01 2.500e+01 -0.560 0.580
## Plant_ID8554325 3.336e+00 2.714e+01 2.500e+01 0.123 0.903
## I(GDD_5C^2):Plant_ID8553606 -1.100e-06 8.464e-06 2.500e+01 -0.130 0.898
## I(GDD_5C^2):Plant_ID8553762 6.981e-06 8.464e-06 2.500e+01 0.825 0.417
## I(GDD_5C^2):Plant_ID8553879 7.012e-07 8.464e-06 2.500e+01 0.083 0.935
## I(GDD_5C^2):Plant_ID8554325 3.859e-06 8.464e-06 2.500e+01 0.456 0.652
##
## Correlation of Fixed Effects:
## (Intr) I(GDD_5C^2) P_ID85536 P_ID85537 P_ID85538 P_ID8554
## I(GDD_5C^2) -0.792
## P_ID8553606 -0.707 0.560
## P_ID8553762 -0.707 0.560 0.500
## P_ID8553879 -0.707 0.560 0.500 0.500
## P_ID8554325 -0.707 0.560 0.500 0.500 0.500
## I(GDD_5C^2):P_ID85536 0.560 -0.707 -0.792 -0.396 -0.396 -0.396
## I(GDD_5C^2):P_ID85537 0.560 -0.707 -0.396 -0.792 -0.396 -0.396
## I(GDD_5C^2):P_ID85538 0.560 -0.707 -0.396 -0.396 -0.792 -0.396
## I(GDD_5C^2):P_ID8554 0.560 -0.707 -0.396 -0.396 -0.396 -0.792
## I(GDD_5C^2):P_ID85536 I(GDD_5C^2):P_ID85537
## I(GDD_5C^2)
## P_ID8553606
## P_ID8553762
## P_ID8553879
## P_ID8554325
## I(GDD_5C^2):P_ID85536
## I(GDD_5C^2):P_ID85537 0.500
## I(GDD_5C^2):P_ID85538 0.500 0.500
## I(GDD_5C^2):P_ID8554 0.500 0.500
## I(GDD_5C^2):P_ID85538
## I(GDD_5C^2)
## P_ID8553606
## P_ID8553762
## P_ID8553879
## P_ID8554325
## I(GDD_5C^2):P_ID85536
## I(GDD_5C^2):P_ID85537
## I(GDD_5C^2):P_ID85538
## I(GDD_5C^2):P_ID8554 0.500
## fit warnings:
## Some predictor variables are on very different scales: consider rescaling
# For Betula
lmm_model_betula_specnumber23 <- lmer(specnumber ~ I(GDD_5C^3) + Plant_ID + I(GDD_5C^3):Plant_ID +
(1 | Plant_ID), data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia"))
## Warning: Some predictor variables are on very different scales: consider
## rescaling
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## unable to evaluate scaled gradient
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## Hessian is numerically singular: parameters are not uniquely determined
## Warning: Some predictor variables are on very different scales: consider
## rescaling
## Warning in as_lmerModLT(model, devfun): Model may not have converged with 1
## eigenvalue close to zero: 3.2e-10
summary(lmm_model_betula_specnumber23)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: specnumber ~ I(GDD_5C^3) + Plant_ID + I(GDD_5C^3):Plant_ID +
## (1 | Plant_ID)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia")
##
## REML criterion at convergence: 481.6
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.7786 -0.3422 -0.1121 0.1913 2.2594
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 236.1 15.36
## Residual 878.6 29.64
## Number of obs: 35, groups: Plant_ID, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 2.861e+01 2.295e+01 2.500e+01 1.247 0.224
## I(GDD_5C^3) 2.203e-09 2.619e-09 2.500e+01 0.841 0.408
## Plant_ID8553606 3.461e+01 3.246e+01 2.500e+01 1.066 0.297
## Plant_ID8553762 -9.954e-01 3.246e+01 2.500e+01 -0.031 0.976
## Plant_ID8553879 -1.444e+01 3.246e+01 2.500e+01 -0.445 0.660
## Plant_ID8554325 6.410e+00 3.246e+01 2.500e+01 0.197 0.845
## I(GDD_5C^3):Plant_ID8553606 -7.638e-10 3.704e-09 2.500e+01 -0.206 0.838
## I(GDD_5C^3):Plant_ID8553762 2.909e-09 3.704e-09 2.500e+01 0.785 0.440
## I(GDD_5C^3):Plant_ID8553879 2.051e-10 3.704e-09 2.500e+01 0.055 0.956
## I(GDD_5C^3):Plant_ID8554325 1.372e-09 3.704e-09 2.500e+01 0.370 0.714
##
## Correlation of Fixed Effects:
## (Intr) I(GDD_5C^3) P_ID85536 P_ID85537 P_ID85538 P_ID8554
## I(GDD_5C^3) -0.560
## P_ID8553606 -0.707 0.396
## P_ID8553762 -0.707 0.396 0.500
## P_ID8553879 -0.707 0.396 0.500 0.500
## P_ID8554325 -0.707 0.396 0.500 0.500 0.500
## I(GDD_5C^3):P_ID85536 0.396 -0.707 -0.560 -0.280 -0.280 -0.280
## I(GDD_5C^3):P_ID85537 0.396 -0.707 -0.280 -0.560 -0.280 -0.280
## I(GDD_5C^3):P_ID85538 0.396 -0.707 -0.280 -0.280 -0.560 -0.280
## I(GDD_5C^3):P_ID8554 0.396 -0.707 -0.280 -0.280 -0.280 -0.560
## I(GDD_5C^3):P_ID85536 I(GDD_5C^3):P_ID85537
## I(GDD_5C^3)
## P_ID8553606
## P_ID8553762
## P_ID8553879
## P_ID8554325
## I(GDD_5C^3):P_ID85536
## I(GDD_5C^3):P_ID85537 0.500
## I(GDD_5C^3):P_ID85538 0.500 0.500
## I(GDD_5C^3):P_ID8554 0.500 0.500
## I(GDD_5C^3):P_ID85538
## I(GDD_5C^3)
## P_ID8553606
## P_ID8553762
## P_ID8553879
## P_ID8554325
## I(GDD_5C^3):P_ID85536
## I(GDD_5C^3):P_ID85537
## I(GDD_5C^3):P_ID85538
## I(GDD_5C^3):P_ID8554 0.500
## fit warnings:
## Some predictor variables are on very different scales: consider rescaling
## optimizer (nloptwrap) convergence code: 0 (OK)
## unable to evaluate scaled gradient
## Hessian is numerically singular: parameters are not uniquely determined
NOTE: The only models with NO singularity issues
are: - lmm_model_betula_specnumber9 -
lmm_model_betula_specnumber10 -
lmm_model_betula_specnumber13 -
lmm_model_betula_specnumber14
#-------------------------------------------------------------------------
## Check Diagnostic Statistics/Assumptions
#-------------------------------------------------------------------------
check_model(lmm_model_betula_specnumber1, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_betula_specnumber2, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_betula_specnumber3, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_betula_specnumber4, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_betula_specnumber5, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_betula_specnumber6, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_betula_specnumber7, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_betula_specnumber8, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_betula_specnumber9, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_betula_specnumber10, check = c("normality", "vif", "linearity",
"homogeneity", "outliers"))
check_model(lmm_model_betula_specnumber11, check = c("normality", "vif", "linearity",
"homogeneity", "outliers"))
check_model(lmm_model_betula_specnumber12, check = c("normality", "vif", "linearity",
"homogeneity", "outliers"))
check_model(lmm_model_betula_specnumber13, check = c("normality", "vif", "linearity",
"homogeneity", "outliers"))
check_model(lmm_model_betula_specnumber14, check = c("normality", "vif", "linearity",
"homogeneity", "outliers"))
check_model(lmm_model_betula_specnumber15, check = c("normality", "vif", "linearity",
"homogeneity", "outliers"))
check_model(lmm_model_betula_specnumber16, check = c("normality", "vif", "linearity",
"homogeneity", "outliers"))
check_model(lmm_model_betula_specnumber17, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_betula_specnumber19, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_betula_specnumber20, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_betula_specnumber21, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_betula_specnumber22, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_betula_specnumber23, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
NOTE: lmm_model_betula_specnumber13
& lmm_model_betula_specnumber14 look best and have no
singularity issues…
BUT: If we ALLOW Singularity, we can also say
lmm_model_betula_specnumber6,
lmm_model_betula_specnumber7, &
lmm_model_betula_specnumber16 also look good.
#-------------------------------------------------------------------------
## To be sure of my model, let's run formal diagnostics:
#-------------------------------------------------------------------------
# Formal Test of Normality (Shapiro-Wilks)
#-------------------------------------------------------------------------
shapiro.test(residuals(lmm_model_betula_specnumber1)) # p=0.3492 -> Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_betula_specnumber1)
## W = 0.9645, p-value = 0.3107
shapiro.test(residuals(lmm_model_betula_specnumber2)) # p=0.9317 -> Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_betula_specnumber2)
## W = 0.98484, p-value = 0.9
shapiro.test(residuals(lmm_model_betula_specnumber3)) # p=0.9008 -> Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_betula_specnumber3)
## W = 0.98455, p-value = 0.8928
shapiro.test(residuals(lmm_model_betula_specnumber4)) # p=0.001712 -> NOT Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_betula_specnumber4)
## W = 0.88369, p-value = 0.001482
shapiro.test(residuals(lmm_model_betula_specnumber5)) # p=0.2846 -> Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_betula_specnumber5)
## W = 0.95802, p-value = 0.1992
shapiro.test(residuals(lmm_model_betula_specnumber6)) # p=0.5055 -> Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_betula_specnumber6)
## W = 0.97295, p-value = 0.5292
shapiro.test(residuals(lmm_model_betula_specnumber7)) # p=0.705 -> Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_betula_specnumber7)
## W = 0.97855, p-value = 0.7116
shapiro.test(residuals(lmm_model_betula_specnumber8)) # p=0.3381 -> Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_betula_specnumber8)
## W = 0.96613, p-value = 0.346
shapiro.test(residuals(lmm_model_betula_specnumber9)) # p=0.4208 -> Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_betula_specnumber9)
## W = 0.96912, p-value = 0.4195
shapiro.test(residuals(lmm_model_betula_specnumber10)) # p=0.1789 -> Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_betula_specnumber10)
## W = 0.95393, p-value = 0.1496
shapiro.test(residuals(lmm_model_betula_specnumber11)) # p=0.1735 -> Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_betula_specnumber11)
## W = 0.95297, p-value = 0.1398
shapiro.test(residuals(lmm_model_betula_specnumber12)) # p=0.1261 -> Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_betula_specnumber12)
## W = 0.95091, p-value = 0.1209
shapiro.test(residuals(lmm_model_betula_specnumber13)) # p=0.6781 -> Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_betula_specnumber13)
## W = 0.97788, p-value = 0.689
shapiro.test(residuals(lmm_model_betula_specnumber14)) # p=0.2961 -> Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_betula_specnumber14)
## W = 0.95882, p-value = 0.2107
shapiro.test(residuals(lmm_model_betula_specnumber15)) # p=0.001568 -> NOT Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_betula_specnumber15)
## W = 0.88417, p-value = 0.001524
shapiro.test(residuals(lmm_model_betula_specnumber16)) # p=0.3932 -> Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_betula_specnumber16)
## W = 0.96828, p-value = 0.3978
shapiro.test(residuals(lmm_model_betula_specnumber17))
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_betula_specnumber17)
## W = 0.95802, p-value = 0.1992
shapiro.test(residuals(lmm_model_betula_specnumber19))
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_betula_specnumber19)
## W = 0.96954, p-value = 0.4309
shapiro.test(residuals(lmm_model_betula_specnumber20))
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_betula_specnumber20)
## W = 0.95153, p-value = 0.1263
shapiro.test(residuals(lmm_model_betula_specnumber21))
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_betula_specnumber21)
## W = 0.9645, p-value = 0.3107
shapiro.test(residuals(lmm_model_betula_specnumber22))
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_betula_specnumber22)
## W = 0.9474, p-value = 0.09427
shapiro.test(residuals(lmm_model_betula_specnumber23))
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_betula_specnumber23)
## W = 0.93035, p-value = 0.02865
# Our likely choices, `lmm_model_betula_specnumber9` or
# `lmm_model_betula_specnumber10`, adhere to Normality.
#-------------------------------------------------------------------------
## Compare Model Fits with anova():
#-------------------------------------------------------------------------
# Compare 'model' with ANOVA model:
anova(lmm_model_betula_specnumber1, lmm_model_betula_specnumber2, lmm_model_betula_specnumber3,
lmm_model_betula_specnumber4, lmm_model_betula_specnumber5, lmm_model_betula_specnumber6,
lmm_model_betula_specnumber7, lmm_model_betula_specnumber8, lmm_model_betula_specnumber9,
lmm_model_betula_specnumber10, lmm_model_betula_specnumber11, lmm_model_betula_specnumber12,
lmm_model_betula_specnumber13, lmm_model_betula_specnumber14, lmm_model_betula_specnumber15,
lmm_model_betula_specnumber16, lmm_model_betula_specnumber17, lmm_model_betula_specnumber19,
lmm_model_betula_specnumber20, lmm_model_betula_specnumber22, lmm_model_betula_specnumber23)
## refitting model(s) with ML (instead of REML)
## Data: subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia")
## Models:
## lmm_model_betula_specnumber8: log(specnumber) ~ GDD_5C + (1 | `Collection-Month`)
## lmm_model_betula_specnumber9: log(specnumber) ~ GDD_5C + (1 | Plant_ID)
## lmm_model_betula_specnumber10: (1/specnumber) ~ GDD_5C + (1 | Plant_ID)
## lmm_model_betula_specnumber11: (1/specnumber) ~ GDD_5C + (1 | `Collection-Month`)
## lmm_model_betula_specnumber6: log(specnumber) ~ GDD_5C + GDD_5C:Plant_ID + (1 | `Collection-Month`)
## lmm_model_betula_specnumber7: log(specnumber) ~ GDD_5C + Plant_ID + (1 | `Collection-Month`)
## lmm_model_betula_specnumber12: specnumber ~ GDD_5C + GDD_5C:Plant_ID + (1 | Plant_ID)
## lmm_model_betula_specnumber13: log(specnumber) ~ GDD_5C + GDD_5C:Plant_ID + (1 | Plant_ID)
## lmm_model_betula_specnumber14: (1/specnumber) ~ GDD_5C + GDD_5C:Plant_ID + (1 | Plant_ID)
## lmm_model_betula_specnumber15: I(specnumber^2) ~ GDD_5C + GDD_5C:Plant_ID + (1 | Plant_ID)
## lmm_model_betula_specnumber16: sqrt(specnumber) ~ GDD_5C + GDD_5C:Plant_ID + (1 | Plant_ID)
## lmm_model_betula_specnumber19: (1/specnumber) ~ GDD_5C + Plant_ID + (1 | Plant_ID)
## lmm_model_betula_specnumber20: specnumber ~ GDD_5C + Plant_ID + (1 | Plant_ID)
## lmm_model_betula_specnumber1: specnumber ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID + (1 | `Collection-Month`)
## lmm_model_betula_specnumber2: sqrt(specnumber) ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID + (1 | `Collection-Month`)
## lmm_model_betula_specnumber3: log(specnumber) ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID + (1 | `Collection-Month`)
## lmm_model_betula_specnumber4: I(specnumber^2) ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID + (1 | `Collection-Month`)
## lmm_model_betula_specnumber5: (1/specnumber) ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID + (1 | `Collection-Month`)
## lmm_model_betula_specnumber17: (1/specnumber) ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID + (1 | Plant_ID)
## lmm_model_betula_specnumber22: specnumber ~ I(GDD_5C^2) + Plant_ID + I(GDD_5C^2):Plant_ID + (1 | Plant_ID)
## lmm_model_betula_specnumber23: specnumber ~ I(GDD_5C^3) + Plant_ID + I(GDD_5C^3):Plant_ID + (1 | Plant_ID)
## npar AIC BIC logLik deviance Chisq Df
## lmm_model_betula_specnumber8 4 66.01 72.23 -29.00 58.01
## lmm_model_betula_specnumber9 4 62.29 68.51 -27.14 54.29 3.7224 0
## lmm_model_betula_specnumber10 4 -184.39 -178.17 96.20 -192.39 246.6773 0
## lmm_model_betula_specnumber11 4 -178.96 -172.74 93.48 -186.96 0.0000 0
## lmm_model_betula_specnumber6 8 65.05 77.49 -24.52 49.05 0.0000 4
## lmm_model_betula_specnumber7 8 59.09 71.54 -21.55 43.09 5.9511 0
## lmm_model_betula_specnumber12 8 342.63 355.08 -163.32 326.63 0.0000 0
## lmm_model_betula_specnumber13 8 65.05 77.49 -24.52 49.05 277.5892 0
## lmm_model_betula_specnumber14 8 -177.27 -164.83 96.63 -193.27 242.3149 0
## lmm_model_betula_specnumber15 8 690.76 703.20 -337.38 674.76 0.0000 0
## lmm_model_betula_specnumber16 8 151.72 164.16 -67.86 135.72 539.0390 0
## lmm_model_betula_specnumber19 8 -188.65 -176.21 102.32 -204.65 340.3701 0
## lmm_model_betula_specnumber20 8 341.17 353.61 -162.58 325.17 0.0000 0
## lmm_model_betula_specnumber1 12 347.66 366.33 -161.83 323.66 1.5073 4
## lmm_model_betula_specnumber2 12 155.21 173.87 -65.60 131.21 192.4544 0
## lmm_model_betula_specnumber3 12 65.47 84.13 -20.73 41.47 89.7383 0
## lmm_model_betula_specnumber4 12 697.11 715.77 -336.55 673.11 0.0000 0
## lmm_model_betula_specnumber5 12 -189.75 -171.09 106.87 -213.75 886.8570 0
## lmm_model_betula_specnumber17 12 -189.75 -171.09 106.87 -213.75 0.0000 0
## lmm_model_betula_specnumber22 12 347.99 366.65 -161.99 323.99 0.0000 0
## lmm_model_betula_specnumber23 12 348.79 367.46 -162.40 324.79 0.0000 0
## Pr(>Chisq)
## lmm_model_betula_specnumber8
## lmm_model_betula_specnumber9
## lmm_model_betula_specnumber10
## lmm_model_betula_specnumber11
## lmm_model_betula_specnumber6 1.0000
## lmm_model_betula_specnumber7
## lmm_model_betula_specnumber12
## lmm_model_betula_specnumber13
## lmm_model_betula_specnumber14
## lmm_model_betula_specnumber15
## lmm_model_betula_specnumber16
## lmm_model_betula_specnumber19
## lmm_model_betula_specnumber20
## lmm_model_betula_specnumber1 0.8253
## lmm_model_betula_specnumber2
## lmm_model_betula_specnumber3
## lmm_model_betula_specnumber4
## lmm_model_betula_specnumber5
## lmm_model_betula_specnumber17
## lmm_model_betula_specnumber22
## lmm_model_betula_specnumber23
# Best/lowest AIC and BIC values for `lmm_model_betula_specnumber5`, BUT:
# terrible residuals, collinearity issues, and singularity issues.
# Next Best: `lmm_model_betula_specnumber10` has the next lowest AIC and BIC
# values (`lmm_model_betula_specnumber11` has low values, BUT a singularity
# issue, likely because GDD and Collection-Month have some collinearity due to
# having temporal characteristics.
# POSSIBLE/LIKELY CHOICE: `lmm_model_betula_specnumber14` -> LOWEST!
# ANOVA of LMM model using `car` package.
library(car)
anova_lmm_betula_specnumber1 <- Anova(lmm_model_betula_specnumber1)
anova_lmm_betula_specnumber2 <- Anova(lmm_model_betula_specnumber2)
anova_lmm_betula_specnumber3 <- Anova(lmm_model_betula_specnumber3)
anova_lmm_betula_specnumber4 <- Anova(lmm_model_betula_specnumber4)
anova_lmm_betula_specnumber5 <- Anova(lmm_model_betula_specnumber5)
anova_lmm_betula_specnumber6 <- Anova(lmm_model_betula_specnumber6)
anova_lmm_betula_specnumber7 <- Anova(lmm_model_betula_specnumber7)
anova_lmm_betula_specnumber8 <- Anova(lmm_model_betula_specnumber8)
anova_lmm_betula_specnumber9 <- Anova(lmm_model_betula_specnumber9)
anova_lmm_betula_specnumber10 <- Anova(lmm_model_betula_specnumber10)
anova_lmm_betula_specnumber11 <- Anova(lmm_model_betula_specnumber11)
anova_lmm_betula_specnumber12 <- Anova(lmm_model_betula_specnumber12)
anova_lmm_betula_specnumber13 <- Anova(lmm_model_betula_specnumber13)
anova_lmm_betula_specnumber14 <- Anova(lmm_model_betula_specnumber14)
anova_lmm_betula_specnumber15 <- Anova(lmm_model_betula_specnumber15)
anova_lmm_betula_specnumber16 <- Anova(lmm_model_betula_specnumber16)
summary(anova_lmm_betula_specnumber1)
## Chisq Df Pr(>Chisq)
## Min. :1.100 Min. :1.0 Min. :0.006187
## 1st Qu.:4.298 1st Qu.:2.5 1st Qu.:0.033309
## Median :7.495 Median :4.0 Median :0.060433
## Mean :5.874 Mean :3.0 Mean :0.320287
## 3rd Qu.:8.261 3rd Qu.:4.0 3rd Qu.:0.477338
## Max. :9.027 Max. :4.0 Max. :0.894243
summary(anova_lmm_betula_specnumber2)
## Chisq Df Pr(>Chisq)
## Min. : 0.8528 Min. :1.0 Min. :0.001514
## 1st Qu.: 5.4572 1st Qu.:2.5 1st Qu.:0.013523
## Median :10.0615 Median :4.0 Median :0.025533
## Mean : 7.3359 Mean :3.0 Mean :0.319426
## 3rd Qu.:10.5775 3rd Qu.:4.0 3rd Qu.:0.478382
## Max. :11.0935 Max. :4.0 Max. :0.931231
summary(anova_lmm_betula_specnumber3)
## Chisq Df Pr(>Chisq)
## Min. : 1.188 Min. :1.0 Min. :0.0002692
## 1st Qu.: 7.231 1st Qu.:2.5 1st Qu.:0.0039216
## Median :13.273 Median :4.0 Median :0.0075740
## Mean : 9.459 Mean :3.0 Mean :0.2959701
## 3rd Qu.:13.594 3rd Qu.:4.0 3rd Qu.:0.4438205
## Max. :13.914 Max. :4.0 Max. :0.8800671
summary(anova_lmm_betula_specnumber4)
## Chisq Df Pr(>Chisq)
## Min. :1.626 Min. :1.0 Min. :0.03814
## 1st Qu.:2.963 1st Qu.:2.5 1st Qu.:0.10352
## Median :4.299 Median :4.0 Median :0.16890
## Mean :4.120 Mean :3.0 Mean :0.33704
## 3rd Qu.:5.367 3rd Qu.:4.0 3rd Qu.:0.48648
## Max. :6.436 Max. :4.0 Max. :0.80407
summary(anova_lmm_betula_specnumber5)
## Chisq Df Pr(>Chisq)
## Min. : 7.424 Min. :1.0 Min. :1.025e-05
## 1st Qu.:13.444 1st Qu.:2.5 1st Qu.:1.417e-04
## Median :19.465 Median :4.0 Median :2.732e-04
## Mean :16.071 Mean :3.0 Mean :3.847e-02
## 3rd Qu.:20.394 3rd Qu.:4.0 3rd Qu.:5.770e-02
## Max. :21.323 Max. :4.0 Max. :1.151e-01
summary(anova_lmm_betula_specnumber6)
## Chisq Df Pr(>Chisq)
## Min. : 8.465 Min. :1.00 Min. :0.0004292
## 1st Qu.: 9.449 1st Qu.:1.75 1st Qu.:0.0193143
## Median :10.432 Median :2.50 Median :0.0381993
## Mean :10.432 Mean :2.50 Mean :0.0381993
## 3rd Qu.:11.416 3rd Qu.:3.25 3rd Qu.:0.0570844
## Max. :12.400 Max. :4.00 Max. :0.0759694
summary(anova_lmm_betula_specnumber7)
## Chisq Df Pr(>Chisq)
## Min. :14.70 Min. :1.00 Min. :0.0001261
## 1st Qu.:14.88 1st Qu.:1.75 1st Qu.:0.0010759
## Median :15.05 Median :2.50 Median :0.0020257
## Mean :15.05 Mean :2.50 Mean :0.0020257
## 3rd Qu.:15.23 3rd Qu.:3.25 3rd Qu.:0.0029754
## Max. :15.41 Max. :4.00 Max. :0.0039252
summary(anova_lmm_betula_specnumber8)
## Chisq Df Pr(>Chisq)
## Min. :10.92 Min. :1 Min. :0.0009499
## 1st Qu.:10.92 1st Qu.:1 1st Qu.:0.0009499
## Median :10.92 Median :1 Median :0.0009499
## Mean :10.92 Mean :1 Mean :0.0009499
## 3rd Qu.:10.92 3rd Qu.:1 3rd Qu.:0.0009499
## Max. :10.92 Max. :1 Max. :0.0009499
summary(anova_lmm_betula_specnumber9)
## Chisq Df Pr(>Chisq)
## Min. :14.7 Min. :1 Min. :0.0001261
## 1st Qu.:14.7 1st Qu.:1 1st Qu.:0.0001261
## Median :14.7 Median :1 Median :0.0001261
## Mean :14.7 Mean :1 Mean :0.0001261
## 3rd Qu.:14.7 3rd Qu.:1 3rd Qu.:0.0001261
## Max. :14.7 Max. :1 Max. :0.0001261
summary(anova_lmm_betula_specnumber10)
## Chisq Df Pr(>Chisq)
## Min. :17.41 Min. :1 Min. :3.014e-05
## 1st Qu.:17.41 1st Qu.:1 1st Qu.:3.014e-05
## Median :17.41 Median :1 Median :3.014e-05
## Mean :17.41 Mean :1 Mean :3.014e-05
## 3rd Qu.:17.41 3rd Qu.:1 3rd Qu.:3.014e-05
## Max. :17.41 Max. :1 Max. :3.014e-05
summary(anova_lmm_betula_specnumber11)
## Chisq Df Pr(>Chisq)
## Min. :11.95 Min. :1 Min. :0.0005462
## 1st Qu.:11.95 1st Qu.:1 1st Qu.:0.0005462
## Median :11.95 Median :1 Median :0.0005462
## Mean :11.95 Mean :1 Mean :0.0005462
## 3rd Qu.:11.95 3rd Qu.:1 3rd Qu.:0.0005462
## Max. :11.95 Max. :1 Max. :0.0005462
summary(anova_lmm_betula_specnumber12)
## Chisq Df Pr(>Chisq)
## Min. :7.986 Min. :1.00 Min. :0.004713
## 1st Qu.:8.097 1st Qu.:1.75 1st Qu.:0.022798
## Median :8.208 Median :2.50 Median :0.040882
## Mean :8.208 Mean :2.50 Mean :0.040882
## 3rd Qu.:8.319 3rd Qu.:3.25 3rd Qu.:0.058967
## Max. :8.430 Max. :4.00 Max. :0.077052
summary(anova_lmm_betula_specnumber13)
## Chisq Df Pr(>Chisq)
## Min. : 0.8612 Min. :1.00 Min. :0.0002692
## 1st Qu.: 3.9643 1st Qu.:1.75 1st Qu.:0.2327152
## Median : 7.0673 Median :2.50 Median :0.4651612
## Mean : 7.0673 Mean :2.50 Mean :0.4651612
## 3rd Qu.:10.1704 3rd Qu.:3.25 3rd Qu.:0.6976073
## Max. :13.2734 Max. :4.00 Max. :0.9300533
summary(anova_lmm_betula_specnumber14)
## Chisq Df Pr(>Chisq)
## Min. : 4.383 Min. :1.00 Min. :0.0000102
## 1st Qu.: 8.153 1st Qu.:1.75 1st Qu.:0.0891825
## Median :11.924 Median :2.50 Median :0.1783548
## Mean :11.924 Mean :2.50 Mean :0.1783548
## 3rd Qu.:15.694 3rd Qu.:3.25 3rd Qu.:0.2675271
## Max. :19.465 Max. :4.00 Max. :0.3566993
summary(anova_lmm_betula_specnumber15)
## Chisq Df Pr(>Chisq)
## Min. :4.757 Min. :1.00 Min. :0.02919
## 1st Qu.:5.463 1st Qu.:1.75 1st Qu.:0.04892
## Median :6.170 Median :2.50 Median :0.06865
## Mean :6.170 Mean :2.50 Mean :0.06865
## 3rd Qu.:6.876 3rd Qu.:3.25 3rd Qu.:0.08838
## Max. :7.583 Max. :4.00 Max. :0.10811
summary(anova_lmm_betula_specnumber16)
## Chisq Df Pr(>Chisq)
## Min. : 8.673 Min. :1.00 Min. :0.00136
## 1st Qu.: 9.070 1st Qu.:1.75 1st Qu.:0.01847
## Median : 9.466 Median :2.50 Median :0.03559
## Mean : 9.466 Mean :2.50 Mean :0.03559
## 3rd Qu.: 9.863 3rd Qu.:3.25 3rd Qu.:0.05270
## Max. :10.259 Max. :4.00 Max. :0.06981
# We want the HIGHEST ChiSq and LOWEST p-value associated with it.
# Here, `lmm_model_betula_specnumber14` seems best!
################################################################################ POSSIBLE
################################################################################ CHOICE:
################################################################################ `lmm_model_betula_specnumber14`
lmm_model_betula_specnumber14 <- lmer((1/specnumber) ~ GDD_5C + GDD_5C:Plant_ID +
(1 | Plant_ID), data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia"))
summary(lmm_model_betula_specnumber14)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: (1/specnumber) ~ GDD_5C + GDD_5C:Plant_ID + (1 | Plant_ID)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia")
##
## REML criterion at convergence: -75.7
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.27658 -0.55382 -0.05178 0.54787 2.20311
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0.0005538 0.02353
## Residual 0.0001825 0.01351
## Number of obs: 35, groups: Plant_ID, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 5.222e-02 1.180e-02 4.000e+00 4.425 0.0115 *
## GDD_5C -1.229e-05 6.968e-06 2.893e+01 -1.764 0.0883 .
## GDD_5C:Plant_ID8553606 2.987e-06 9.662e-06 2.807e+01 0.309 0.7595
## GDD_5C:Plant_ID8553762 1.035e-06 9.662e-06 2.807e+01 0.107 0.9154
## GDD_5C:Plant_ID8553879 -1.494e-05 9.662e-06 2.807e+01 -1.546 0.1333
## GDD_5C:Plant_ID8554325 -1.484e-06 9.662e-06 2.807e+01 -0.154 0.8790
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C GDD_5C:P_ID85536 GDD_5C:P_ID85537
## GDD_5C -0.196
## GDD_5C:P_ID85536 0.000 -0.693
## GDD_5C:P_ID85537 0.000 -0.693 0.500
## GDD_5C:P_ID85538 0.000 -0.693 0.500 0.500
## GDD_5C:P_ID8554 0.000 -0.693 0.500 0.500
## GDD_5C:P_ID85538
## GDD_5C
## GDD_5C:P_ID85536
## GDD_5C:P_ID85537
## GDD_5C:P_ID85538
## GDD_5C:P_ID8554 0.500
#------------------------------------------------------------------------------------
## Marginal R^2 for `GDD_5C` only
#------------------------------------------------------------------------------------
# Fit the linear mixed-effects model with just `Species`
lmm_model_specnumber_betula_gdd <- lmer(log(specnumber) ~ GDD_5C + (1 | Plant_ID),
data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia"))
# Calculate marginal R-squared for `Species`
specnumber_marginal_r_squared_betula_gdd <- r.squaredGLMM(lmm_model_specnumber_betula_gdd,
mu0 = "fixed")
print(specnumber_marginal_r_squared_betula_gdd)
## R2m R2c
## [1,] 0.2349852 0.4564487
#------------------------------------------------------------------------------------
## Marginal R^2 for `Plant_ID:GDD_5C` interaction only
#------------------------------------------------------------------------------------
# Fit the linear mixed-effects model with just `Species`
lmm_model_specnumber_betula_interaction <- lmer(log(specnumber) ~ Plant_ID:GDD_5C +
(1 | Plant_ID), data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia"))
# Calculate marginal R-squared for `Species`
specnumber_marginal_r_squared_betula_interaction <- r.squaredGLMM(lmm_model_specnumber_betula_interaction,
mu0 = "fixed")
print(specnumber_marginal_r_squared_betula_interaction)
## R2m R2c
## [1,] 0.2450708 0.4601041
#--------------------------------------------------------------
## Conditional & Marginal R^2 for Model overall!
#--------------------------------------------------------------
# Calculate marginal R-squared for `GDD_5C`
betula_specnumber_r_squared <- r.squaredGLMM(lmm_model_betula_specnumber14, mu0 = "fixed")
print(betula_specnumber_r_squared)
## R2m R2c
## [1,] 0.2231643 0.8074307
NOTE: This HIGH R2c (conditional R^2) is a bit suspect, since it’s saying over 80% of variance is being explained. This indicates possible overfitting to me, especially due to model complexity. Therefore, our ACTUAL CHOICE will be:
################################################################################ ULTIMATE
################################################################################ CHOICE:
################################################################################ `lmm_model_betula_specnumber10`
lmm_model_betula_specnumber10 <- lmer((1/specnumber) ~ GDD_5C + (1 | Plant_ID), data = subset(asv_scaled_noPlants_Phen_filt_LMM,
Species == "Betula_populifolia"))
summary(lmm_model_betula_specnumber10)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: (1/specnumber) ~ GDD_5C + (1 | Plant_ID)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia")
##
## REML criterion at convergence: -160.3
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.48626 -0.50298 -0.03675 0.52908 2.69893
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0.0001099 0.01048
## Residual 0.0002041 0.01429
## Number of obs: 35, groups: Plant_ID, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 5.222e-02 7.336e-03 1.337e+01 7.118 6.7e-06 ***
## GDD_5C -1.477e-05 3.540e-06 2.900e+01 -4.172 0.00025 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## GDD_5C -0.695
#--------------------------------------------------------------
## Conditional & Marginal R^2 for Model overall!
#--------------------------------------------------------------
# Calculate marginal R-squared for `GDD_5C`
betula_specnumber_r_squared <- r.squaredGLMM(lmm_model_betula_specnumber10, mu0 = "fixed")
print(betula_specnumber_r_squared)
## R2m R2c
## [1,] 0.2497348 0.5122702
# install.packages('urca')
library(urca)
# Perform KPSS test
kpss_betula_specnumber <- ur.kpss(betula_data$specnumber)
kpss_betula_specnumber <- ur.kpss(asv_scaled_noPlants_Phen_filt_LMM$specnumber[asv_scaled_noPlants_Phen_filt_LMM$Species ==
"Betula_populifolia"])
# summary of KPSS Test
summary(kpss_betula_specnumber)
##
## #######################
## # KPSS Unit Root Test #
## #######################
##
## Test is of type: mu with 3 lags.
##
## Value of test-statistic is: 0.1308
##
## Critical value for a significance level of:
## 10pct 5pct 2.5pct 1pct
## critical values 0.347 0.463 0.574 0.739
# OUTPUT: ASV richness in Betula is STATIONARY!
# For Populus
lmm_model_populus_specnumber1 <- lmer(specnumber ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID +
(1 | `Collection-Month`), data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species ==
"Populus_tremuloides"))
## boundary (singular) fit: see help('isSingular')
summary(lmm_model_populus_specnumber1)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## specnumber ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID + (1 | `Collection-Month`)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides")
##
## REML criterion at convergence: 327.1
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.4816 -0.6520 -0.1618 0.5913 2.1148
##
## Random effects:
## Groups Name Variance Std.Dev.
## Collection-Month (Intercept) 0.0 0.00
## Residual 650.8 25.51
## Number of obs: 36, groups: Collection-Month, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 66.298330 21.410900 26.000000 3.096 0.00465 **
## GDD_5C -0.002988 0.013904 26.000000 -0.215 0.83151
## Plant_ID8987955 -31.471002 31.084377 26.000000 -1.012 0.32066
## Plant_ID8988752 7.643543 31.084377 26.000000 0.246 0.80769
## Plant_ID8988899 -29.520854 31.084377 26.000000 -0.950 0.35101
## Plant_ID9340742 -32.316724 31.084377 26.000000 -1.040 0.30808
## GDD_5C:Plant_ID8987955 0.011139 0.019828 26.000000 0.562 0.57907
## GDD_5C:Plant_ID8988752 -0.021362 0.019828 26.000000 -1.077 0.29121
## GDD_5C:Plant_ID8988899 0.014545 0.019828 26.000000 0.734 0.46979
## GDD_5C:Plant_ID9340742 0.015097 0.019828 26.000000 0.761 0.45327
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C P_ID8987 P_ID89887 P_ID89888 P_ID93
## GDD_5C -0.907
## P_ID8987955 -0.689 0.625
## P_ID8988752 -0.689 0.625 0.474
## P_ID8988899 -0.689 0.625 0.474 0.474
## P_ID9340742 -0.689 0.625 0.474 0.474 0.474
## GDD_5C:P_ID8987 0.636 -0.701 -0.905 -0.438 -0.438 -0.438
## GDD_5C:P_ID89887 0.636 -0.701 -0.438 -0.905 -0.438 -0.438
## GDD_5C:P_ID89888 0.636 -0.701 -0.438 -0.438 -0.905 -0.438
## GDD_5C:P_ID9 0.636 -0.701 -0.438 -0.438 -0.438 -0.905
## GDD_5C:P_ID8987 GDD_5C:P_ID89887 GDD_5C:P_ID89888
## GDD_5C
## P_ID8987955
## P_ID8988752
## P_ID8988899
## P_ID9340742
## GDD_5C:P_ID8987
## GDD_5C:P_ID89887 0.492
## GDD_5C:P_ID89888 0.492 0.492
## GDD_5C:P_ID9 0.492 0.492 0.492
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
# For Populus
lmm_model_populus_specnumber2 <- lmer(sqrt(specnumber) ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID +
(1 | `Collection-Month`), data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species ==
"Populus_tremuloides"))
## boundary (singular) fit: see help('isSingular')
summary(lmm_model_populus_specnumber2)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: sqrt(specnumber) ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID + (1 |
## `Collection-Month`)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides")
##
## REML criterion at convergence: 186.6
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.58775 -0.62098 -0.08964 0.69535 1.78621
##
## Random effects:
## Groups Name Variance Std.Dev.
## Collection-Month (Intercept) 0.000 0.000
## Residual 2.931 1.712
## Number of obs: 36, groups: Collection-Month, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 7.9505245 1.4369902 26.0000000 5.533 8.29e-06 ***
## GDD_5C -0.0001768 0.0009332 26.0000000 -0.189 0.851
## Plant_ID8987955 -2.0661478 2.0862246 26.0000000 -0.990 0.331
## Plant_ID8988752 0.6925723 2.0862246 26.0000000 0.332 0.743
## Plant_ID8988899 -1.7107665 2.0862246 26.0000000 -0.820 0.420
## Plant_ID9340742 -2.0298298 2.0862246 26.0000000 -0.973 0.340
## GDD_5C:Plant_ID8987955 0.0007230 0.0013307 26.0000000 0.543 0.592
## GDD_5C:Plant_ID8988752 -0.0016942 0.0013307 26.0000000 -1.273 0.214
## GDD_5C:Plant_ID8988899 0.0007637 0.0013307 26.0000000 0.574 0.571
## GDD_5C:Plant_ID9340742 0.0009870 0.0013307 26.0000000 0.742 0.465
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C P_ID8987 P_ID89887 P_ID89888 P_ID93
## GDD_5C -0.907
## P_ID8987955 -0.689 0.625
## P_ID8988752 -0.689 0.625 0.474
## P_ID8988899 -0.689 0.625 0.474 0.474
## P_ID9340742 -0.689 0.625 0.474 0.474 0.474
## GDD_5C:P_ID8987 0.636 -0.701 -0.905 -0.438 -0.438 -0.438
## GDD_5C:P_ID89887 0.636 -0.701 -0.438 -0.905 -0.438 -0.438
## GDD_5C:P_ID89888 0.636 -0.701 -0.438 -0.438 -0.905 -0.438
## GDD_5C:P_ID9 0.636 -0.701 -0.438 -0.438 -0.438 -0.905
## GDD_5C:P_ID8987 GDD_5C:P_ID89887 GDD_5C:P_ID89888
## GDD_5C
## P_ID8987955
## P_ID8988752
## P_ID8988899
## P_ID9340742
## GDD_5C:P_ID8987
## GDD_5C:P_ID89887 0.492
## GDD_5C:P_ID89888 0.492 0.492
## GDD_5C:P_ID9 0.492 0.492 0.492
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
# For Populus
lmm_model_populus_specnumber3 <- lmer(log(specnumber) ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID +
(1 | `Collection-Month`), data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species ==
"Populus_tremuloides"))
## boundary (singular) fit: see help('isSingular')
summary(lmm_model_populus_specnumber3)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: log(specnumber) ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID + (1 |
## `Collection-Month`)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides")
##
## REML criterion at convergence: 121.9
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.78252 -0.55273 -0.01922 0.73094 1.44316
##
## Random effects:
## Groups Name Variance Std.Dev.
## Collection-Month (Intercept) 0.0000 0.0000
## Residual 0.2434 0.4933
## Number of obs: 36, groups: Collection-Month, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 4.104e+00 4.140e-01 2.600e+01 9.911 2.55e-10 ***
## GDD_5C -4.423e-05 2.689e-04 2.600e+01 -0.164 0.871
## Plant_ID8987955 -5.684e-01 6.011e-01 2.600e+01 -0.946 0.353
## Plant_ID8988752 2.437e-01 6.011e-01 2.600e+01 0.405 0.688
## Plant_ID8988899 -4.047e-01 6.011e-01 2.600e+01 -0.673 0.507
## Plant_ID9340742 -5.281e-01 6.011e-01 2.600e+01 -0.879 0.388
## GDD_5C:Plant_ID8987955 1.903e-04 3.834e-04 2.600e+01 0.496 0.624
## GDD_5C:Plant_ID8988752 -5.627e-04 3.834e-04 2.600e+01 -1.467 0.154
## GDD_5C:Plant_ID8988899 1.495e-04 3.834e-04 2.600e+01 0.390 0.700
## GDD_5C:Plant_ID9340742 2.646e-04 3.834e-04 2.600e+01 0.690 0.496
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C P_ID8987 P_ID89887 P_ID89888 P_ID93
## GDD_5C -0.907
## P_ID8987955 -0.689 0.625
## P_ID8988752 -0.689 0.625 0.474
## P_ID8988899 -0.689 0.625 0.474 0.474
## P_ID9340742 -0.689 0.625 0.474 0.474 0.474
## GDD_5C:P_ID8987 0.636 -0.701 -0.905 -0.438 -0.438 -0.438
## GDD_5C:P_ID89887 0.636 -0.701 -0.438 -0.905 -0.438 -0.438
## GDD_5C:P_ID89888 0.636 -0.701 -0.438 -0.438 -0.905 -0.438
## GDD_5C:P_ID9 0.636 -0.701 -0.438 -0.438 -0.438 -0.905
## GDD_5C:P_ID8987 GDD_5C:P_ID89887 GDD_5C:P_ID89888
## GDD_5C
## P_ID8987955
## P_ID8988752
## P_ID8988899
## P_ID9340742
## GDD_5C:P_ID8987
## GDD_5C:P_ID89887 0.492
## GDD_5C:P_ID89888 0.492 0.492
## GDD_5C:P_ID9 0.492 0.492 0.492
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
# For Populus
lmm_model_populus_specnumber4 <- lmer(I(specnumber^2) ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID +
(1 | `Collection-Month`), data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species ==
"Populus_tremuloides"))
## boundary (singular) fit: see help('isSingular')
summary(lmm_model_populus_specnumber4)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: I(specnumber^2) ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID + (1 |
## `Collection-Month`)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides")
##
## REML criterion at convergence: 580.5
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.2463 -0.6050 -0.1708 0.3241 2.6539
##
## Random effects:
## Groups Name Variance Std.Dev.
## Collection-Month (Intercept) 0 0
## Residual 11131506 3336
## Number of obs: 36, groups: Collection-Month, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 5369.3851 2800.1905 26.0000 1.918 0.0662 .
## GDD_5C -0.4921 1.8184 26.0000 -0.271 0.7888
## Plant_ID8987955 -4168.7744 4065.3208 26.0000 -1.025 0.3146
## Plant_ID8988752 188.3899 4065.3208 26.0000 0.046 0.9634
## Plant_ID8988899 -4664.9571 4065.3208 26.0000 -1.148 0.2616
## Plant_ID9340742 -4509.0304 4065.3208 26.0000 -1.109 0.2775
## GDD_5C:Plant_ID8987955 1.4108 2.5931 26.0000 0.544 0.5911
## GDD_5C:Plant_ID8988752 -1.8895 2.5931 26.0000 -0.729 0.4727
## GDD_5C:Plant_ID8988899 2.4688 2.5931 26.0000 0.952 0.3498
## GDD_5C:Plant_ID9340742 1.9033 2.5931 26.0000 0.734 0.4695
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C P_ID8987 P_ID89887 P_ID89888 P_ID93
## GDD_5C -0.907
## P_ID8987955 -0.689 0.625
## P_ID8988752 -0.689 0.625 0.474
## P_ID8988899 -0.689 0.625 0.474 0.474
## P_ID9340742 -0.689 0.625 0.474 0.474 0.474
## GDD_5C:P_ID8987 0.636 -0.701 -0.905 -0.438 -0.438 -0.438
## GDD_5C:P_ID89887 0.636 -0.701 -0.438 -0.905 -0.438 -0.438
## GDD_5C:P_ID89888 0.636 -0.701 -0.438 -0.438 -0.905 -0.438
## GDD_5C:P_ID9 0.636 -0.701 -0.438 -0.438 -0.438 -0.905
## GDD_5C:P_ID8987 GDD_5C:P_ID89887 GDD_5C:P_ID89888
## GDD_5C
## P_ID8987955
## P_ID8988752
## P_ID8988899
## P_ID9340742
## GDD_5C:P_ID8987
## GDD_5C:P_ID89887 0.492
## GDD_5C:P_ID89888 0.492 0.492
## GDD_5C:P_ID9 0.492 0.492 0.492
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
# For Populus
lmm_model_populus_specnumber5 <- lmer((1/specnumber) ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID +
(1 | `Collection-Month`), data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species ==
"Populus_tremuloides"))
## boundary (singular) fit: see help('isSingular')
summary(lmm_model_populus_specnumber5)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## (1/specnumber) ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID + (1 | `Collection-Month`)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides")
##
## REML criterion at convergence: -66.2
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.2484 -0.6974 -0.0720 0.3270 2.2515
##
## Random effects:
## Groups Name Variance Std.Dev.
## Collection-Month (Intercept) 0.0000000 0.00000
## Residual 0.0001756 0.01325
## Number of obs: 36, groups: Collection-Month, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 1.766e-02 1.112e-02 2.600e+01 1.588 0.1245
## GDD_5C 8.139e-07 7.223e-06 2.600e+01 0.113 0.9112
## Plant_ID8987955 1.229e-02 1.615e-02 2.600e+01 0.761 0.4535
## Plant_ID8988752 -8.192e-03 1.615e-02 2.600e+01 -0.507 0.6162
## Plant_ID8988899 5.944e-03 1.615e-02 2.600e+01 0.368 0.7158
## Plant_ID9340742 9.947e-03 1.615e-02 2.600e+01 0.616 0.5433
## GDD_5C:Plant_ID8987955 -3.281e-06 1.030e-05 2.600e+01 -0.318 0.7527
## GDD_5C:Plant_ID8988752 1.807e-05 1.030e-05 2.600e+01 1.754 0.0912 .
## GDD_5C:Plant_ID8988899 -3.662e-07 1.030e-05 2.600e+01 -0.036 0.9719
## GDD_5C:Plant_ID9340742 -5.120e-06 1.030e-05 2.600e+01 -0.497 0.6233
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C P_ID8987 P_ID89887 P_ID89888 P_ID93
## GDD_5C -0.907
## P_ID8987955 -0.689 0.625
## P_ID8988752 -0.689 0.625 0.474
## P_ID8988899 -0.689 0.625 0.474 0.474
## P_ID9340742 -0.689 0.625 0.474 0.474 0.474
## GDD_5C:P_ID8987 0.636 -0.701 -0.905 -0.438 -0.438 -0.438
## GDD_5C:P_ID89887 0.636 -0.701 -0.438 -0.905 -0.438 -0.438
## GDD_5C:P_ID89888 0.636 -0.701 -0.438 -0.438 -0.905 -0.438
## GDD_5C:P_ID9 0.636 -0.701 -0.438 -0.438 -0.438 -0.905
## GDD_5C:P_ID8987 GDD_5C:P_ID89887 GDD_5C:P_ID89888
## GDD_5C
## P_ID8987955
## P_ID8988752
## P_ID8988899
## P_ID9340742
## GDD_5C:P_ID8987
## GDD_5C:P_ID89887 0.492
## GDD_5C:P_ID89888 0.492 0.492
## GDD_5C:P_ID9 0.492 0.492 0.492
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
# NOTE: `lmm_model_populus_specnumber3` is most promising, BUT `Plant_ID` and
# `GDD_5C:Plant_ID` have high VIFs. So, let's try dropping `Plant_ID` itself.
lmm_model_populus_specnumber6 <- lmer(log(specnumber) ~ GDD_5C + GDD_5C:Plant_ID +
(1 | `Collection-Month`), data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species ==
"Populus_tremuloides"))
## boundary (singular) fit: see help('isSingular')
summary(lmm_model_populus_specnumber6)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: log(specnumber) ~ GDD_5C + GDD_5C:Plant_ID + (1 | `Collection-Month`)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides")
##
## REML criterion at convergence: 126.8
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.8817 -0.5292 -0.1386 0.6127 1.6972
##
## Random effects:
## Groups Name Variance Std.Dev.
## Collection-Month (Intercept) 0.0000 0.0000
## Residual 0.2329 0.4826
## Number of obs: 36, groups: Collection-Month, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 3.857e+00 1.886e-01 3.000e+01 20.448 <2e-16 ***
## GDD_5C 1.008e-04 1.569e-04 3.000e+01 0.642 0.5256
## GDD_5C:Plant_ID8987955 -1.374e-04 1.593e-04 3.000e+01 -0.862 0.3954
## GDD_5C:Plant_ID8988752 -4.299e-04 1.593e-04 3.000e+01 -2.698 0.0113 *
## GDD_5C:Plant_ID8988899 -8.535e-05 1.593e-04 3.000e+01 -0.536 0.5961
## GDD_5C:Plant_ID9340742 -4.019e-05 1.593e-04 3.000e+01 -0.252 0.8026
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C GDD_5C:P_ID8987 GDD_5C:P_ID89887
## GDD_5C -0.708
## GDD_5C:P_ID8987 0.026 -0.510
## GDD_5C:P_ID89887 0.026 -0.510 0.484
## GDD_5C:P_ID89888 0.026 -0.510 0.484 0.484
## GDD_5C:P_ID9 0.026 -0.510 0.484 0.484
## GDD_5C:P_ID89888
## GDD_5C
## GDD_5C:P_ID8987
## GDD_5C:P_ID89887
## GDD_5C:P_ID89888
## GDD_5C:P_ID9 0.484
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
# For Populus
lmm_model_populus_specnumber7 <- lmer(log(specnumber) ~ GDD_5C + Plant_ID + (1 |
`Collection-Month`), data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species ==
"Populus_tremuloides"))
## boundary (singular) fit: see help('isSingular')
summary(lmm_model_populus_specnumber7)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: log(specnumber) ~ GDD_5C + Plant_ID + (1 | `Collection-Month`)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides")
##
## REML criterion at convergence: 71.1
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.7443 -0.5462 -0.0739 0.6743 1.9141
##
## Random effects:
## Groups Name Variance Std.Dev.
## Collection-Month (Intercept) 0.0000 0.0000
## Residual 0.2592 0.5091
## Number of obs: 36, groups: Collection-Month, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 4.092e+00 2.515e-01 3.000e+01 16.272 <2e-16 ***
## GDD_5C -3.593e-05 1.257e-04 3.000e+01 -0.286 0.7770
## Plant_ID8987955 -2.946e-01 2.636e-01 3.000e+01 -1.118 0.2725
## Plant_ID8988752 -5.674e-01 2.636e-01 3.000e+01 -2.153 0.0395 *
## Plant_ID8988899 -1.896e-01 2.636e-01 3.000e+01 -0.720 0.4774
## Plant_ID9340742 -1.472e-01 2.636e-01 3.000e+01 -0.558 0.5807
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C P_ID8987 P_ID89887 P_ID89888
## GDD_5C -0.698
## P_ID8987955 -0.474 -0.021
## P_ID8988752 -0.474 -0.021 0.467
## P_ID8988899 -0.474 -0.021 0.467 0.467
## P_ID9340742 -0.474 -0.021 0.467 0.467 0.467
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
# For Populus
lmm_model_populus_specnumber8 <- lmer(log(specnumber) ~ GDD_5C + (1 | `Collection-Month`),
data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides"))
## boundary (singular) fit: see help('isSingular')
summary(lmm_model_populus_specnumber8)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: log(specnumber) ~ GDD_5C + (1 | `Collection-Month`)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides")
##
## REML criterion at convergence: 71.8
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.35934 -0.68032 -0.01915 0.69601 1.81980
##
## Random effects:
## Groups Name Variance Std.Dev.
## Collection-Month (Intercept) 0.0000 0.0000
## Residual 0.2672 0.5169
## Number of obs: 36, groups: Collection-Month, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 3.866e+00 2.019e-01 3.400e+01 19.147 <2e-16 ***
## GDD_5C -4.096e-05 1.276e-04 3.400e+01 -0.321 0.75
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## GDD_5C -0.904
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
# For Populus
lmm_model_populus_specnumber9 <- lmer(log(specnumber) ~ GDD_5C + (1 | Plant_ID),
data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides"))
summary(lmm_model_populus_specnumber9)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: log(specnumber) ~ GDD_5C + (1 | Plant_ID)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides")
##
## REML criterion at convergence: 71.7
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.2571 -0.5608 -0.1170 0.7440 1.7446
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0.009952 0.09976
## Residual 0.258719 0.50864
## Number of obs: 36, groups: Plant_ID, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 3.8628701 0.2036922 30.8052429 18.964 <2e-16 ***
## GDD_5C -0.0000398 0.0001256 30.1538579 -0.317 0.753
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## GDD_5C -0.882
# For Populus
lmm_model_populus_specnumber10 <- lmer((1/specnumber) ~ GDD_5C + (1 | Plant_ID),
data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides"))
summary(lmm_model_populus_specnumber10)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: (1/specnumber) ~ GDD_5C + (1 | Plant_ID)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides")
##
## REML criterion at convergence: -172.4
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.2654 -0.7350 -0.0928 0.2893 3.2750
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 2.072e-05 0.004552
## Residual 1.898e-04 0.013775
## Number of obs: 36, groups: Plant_ID, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 2.148e-02 5.756e-03 2.678e+01 3.733 0.000903 ***
## GDD_5C 2.737e-06 3.401e-06 3.005e+01 0.805 0.427322
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## GDD_5C -0.846
lmm_model_populus_specnumber11 <- lmer(specnumber ~ GDD_5C + GDD_5C:Plant_ID + (1 |
Plant_ID), data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides"))
## boundary (singular) fit: see help('isSingular')
summary(lmm_model_populus_specnumber11)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: specnumber ~ GDD_5C + GDD_5C:Plant_ID + (1 | Plant_ID)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides")
##
## REML criterion at convergence: 363.9
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.4410 -0.5720 -0.2637 0.4437 2.3912
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0.0 0.00
## Residual 629.3 25.09
## Number of obs: 36, groups: Plant_ID, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 49.526677 9.804886 30.000000 5.051 2.02e-05 ***
## GDD_5C 0.006890 0.008156 30.000000 0.845 0.4049
## GDD_5C:Plant_ID8987955 -0.007073 0.008282 30.000000 -0.854 0.3999
## GDD_5C:Plant_ID8988752 -0.017397 0.008282 30.000000 -2.101 0.0442 *
## GDD_5C:Plant_ID8988899 -0.002562 0.008282 30.000000 -0.309 0.7592
## GDD_5C:Plant_ID9340742 -0.003594 0.008282 30.000000 -0.434 0.6674
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C GDD_5C:P_ID8987 GDD_5C:P_ID89887
## GDD_5C -0.708
## GDD_5C:P_ID8987 0.026 -0.510
## GDD_5C:P_ID89887 0.026 -0.510 0.484
## GDD_5C:P_ID89888 0.026 -0.510 0.484 0.484
## GDD_5C:P_ID9 0.026 -0.510 0.484 0.484
## GDD_5C:P_ID89888
## GDD_5C
## GDD_5C:P_ID8987
## GDD_5C:P_ID89887
## GDD_5C:P_ID89888
## GDD_5C:P_ID9 0.484
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
lmm_model_populus_specnumber12 <- lmer(log(specnumber) ~ GDD_5C + GDD_5C:Plant_ID +
(1 | Plant_ID), data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides"))
## boundary (singular) fit: see help('isSingular')
summary(lmm_model_populus_specnumber12)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: log(specnumber) ~ GDD_5C + GDD_5C:Plant_ID + (1 | Plant_ID)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides")
##
## REML criterion at convergence: 126.8
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.8817 -0.5292 -0.1386 0.6127 1.6972
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0.0000 0.0000
## Residual 0.2329 0.4826
## Number of obs: 36, groups: Plant_ID, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 3.857e+00 1.886e-01 3.000e+01 20.448 <2e-16 ***
## GDD_5C 1.008e-04 1.569e-04 3.000e+01 0.642 0.5256
## GDD_5C:Plant_ID8987955 -1.374e-04 1.593e-04 3.000e+01 -0.862 0.3954
## GDD_5C:Plant_ID8988752 -4.299e-04 1.593e-04 3.000e+01 -2.698 0.0113 *
## GDD_5C:Plant_ID8988899 -8.535e-05 1.593e-04 3.000e+01 -0.536 0.5961
## GDD_5C:Plant_ID9340742 -4.019e-05 1.593e-04 3.000e+01 -0.252 0.8026
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C GDD_5C:P_ID8987 GDD_5C:P_ID89887
## GDD_5C -0.708
## GDD_5C:P_ID8987 0.026 -0.510
## GDD_5C:P_ID89887 0.026 -0.510 0.484
## GDD_5C:P_ID89888 0.026 -0.510 0.484 0.484
## GDD_5C:P_ID9 0.026 -0.510 0.484 0.484
## GDD_5C:P_ID89888
## GDD_5C
## GDD_5C:P_ID8987
## GDD_5C:P_ID89887
## GDD_5C:P_ID89888
## GDD_5C:P_ID9 0.484
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
lmm_model_populus_specnumber13 <- lmer((1/specnumber) ~ GDD_5C + GDD_5C:Plant_ID +
(1 | Plant_ID), data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides"))
## boundary (singular) fit: see help('isSingular')
summary(lmm_model_populus_specnumber13)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: (1/specnumber) ~ GDD_5C + GDD_5C:Plant_ID + (1 | Plant_ID)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides")
##
## REML criterion at convergence: -90.9
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.46560 -0.67879 -0.01366 0.35404 2.45286
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0.0000000 0.0000
## Residual 0.0001639 0.0128
## Number of obs: 36, groups: Plant_ID, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 2.157e-02 5.004e-03 3.000e+01 4.311 0.000162 ***
## GDD_5C -1.491e-06 4.163e-06 3.000e+01 -0.358 0.722738
## GDD_5C:Plant_ID8987955 3.773e-06 4.227e-06 3.000e+01 0.893 0.379155
## GDD_5C:Plant_ID8988752 1.351e-05 4.227e-06 3.000e+01 3.196 0.003270 **
## GDD_5C:Plant_ID8988899 3.090e-06 4.227e-06 3.000e+01 0.731 0.470462
## GDD_5C:Plant_ID9340742 6.054e-07 4.227e-06 3.000e+01 0.143 0.887078
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C GDD_5C:P_ID8987 GDD_5C:P_ID89887
## GDD_5C -0.708
## GDD_5C:P_ID8987 0.026 -0.510
## GDD_5C:P_ID89887 0.026 -0.510 0.484
## GDD_5C:P_ID89888 0.026 -0.510 0.484 0.484
## GDD_5C:P_ID9 0.026 -0.510 0.484 0.484
## GDD_5C:P_ID89888
## GDD_5C
## GDD_5C:P_ID8987
## GDD_5C:P_ID89887
## GDD_5C:P_ID89888
## GDD_5C:P_ID9 0.484
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
lmm_model_populus_specnumber14 <- lmer(I(specnumber^2) ~ GDD_5C + GDD_5C:Plant_ID +
(1 | Plant_ID), data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides"))
## boundary (singular) fit: see help('isSingular')
summary(lmm_model_populus_specnumber14)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: I(specnumber^2) ~ GDD_5C + GDD_5C:Plant_ID + (1 | Plant_ID)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides")
##
## REML criterion at convergence: 656.2
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.1862 -0.5268 -0.3047 0.2460 2.9843
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0 0
## Residual 10742192 3278
## Number of obs: 36, groups: Plant_ID, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 2793.9988 1281.0312 30.0000 2.181 0.0372 *
## GDD_5C 1.0247 1.0656 30.0000 0.962 0.3439
## GDD_5C:Plant_ID8987955 -1.0094 1.0821 30.0000 -0.933 0.3583
## GDD_5C:Plant_ID8988752 -1.8393 1.0821 30.0000 -1.700 0.0995 .
## GDD_5C:Plant_ID8988899 -0.2327 1.0821 30.0000 -0.215 0.8312
## GDD_5C:Plant_ID9340742 -0.7098 1.0821 30.0000 -0.656 0.5169
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C GDD_5C:P_ID8987 GDD_5C:P_ID89887
## GDD_5C -0.708
## GDD_5C:P_ID8987 0.026 -0.510
## GDD_5C:P_ID89887 0.026 -0.510 0.484
## GDD_5C:P_ID89888 0.026 -0.510 0.484 0.484
## GDD_5C:P_ID9 0.026 -0.510 0.484 0.484
## GDD_5C:P_ID89888
## GDD_5C
## GDD_5C:P_ID8987
## GDD_5C:P_ID89887
## GDD_5C:P_ID89888
## GDD_5C:P_ID9 0.484
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
lmm_model_populus_specnumber15 <- lmer(sqrt(specnumber) ~ GDD_5C + GDD_5C:Plant_ID +
(1 | Plant_ID), data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides"))
## boundary (singular) fit: see help('isSingular')
summary(lmm_model_populus_specnumber15)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: sqrt(specnumber) ~ GDD_5C + GDD_5C:Plant_ID + (1 | Plant_ID)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides")
##
## REML criterion at convergence: 201.7
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.5626 -0.5670 -0.2055 0.5250 2.0336
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0.000 0.000
## Residual 2.826 1.681
## Number of obs: 36, groups: Plant_ID, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 6.9492628 0.6570236 30.0000000 10.577 1.22e-11 ***
## GDD_5C 0.0004129 0.0005465 30.0000000 0.756 0.4558
## GDD_5C:Plant_ID8987955 -0.0004704 0.0005550 30.0000000 -0.848 0.4033
## GDD_5C:Plant_ID8988752 -0.0013235 0.0005550 30.0000000 -2.385 0.0236 *
## GDD_5C:Plant_ID8988899 -0.0002283 0.0005550 30.0000000 -0.411 0.6837
## GDD_5C:Plant_ID9340742 -0.0001858 0.0005550 30.0000000 -0.335 0.7400
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C GDD_5C:P_ID8987 GDD_5C:P_ID89887
## GDD_5C -0.708
## GDD_5C:P_ID8987 0.026 -0.510
## GDD_5C:P_ID89887 0.026 -0.510 0.484
## GDD_5C:P_ID89888 0.026 -0.510 0.484 0.484
## GDD_5C:P_ID9 0.026 -0.510 0.484 0.484
## GDD_5C:P_ID89888
## GDD_5C
## GDD_5C:P_ID8987
## GDD_5C:P_ID89887
## GDD_5C:P_ID89888
## GDD_5C:P_ID9 0.484
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
# For Populus
lmm_model_populus_specnumber16 <- lmer((1/specnumber) ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID +
(1 | Plant_ID), data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides"))
## Warning in as_lmerModLT(model, devfun): Model may not have converged with 1
## eigenvalue close to zero: 3.4e-10
summary(lmm_model_populus_specnumber16)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: (1/specnumber) ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID + (1 | Plant_ID)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides")
##
## REML criterion at convergence: -66.2
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.2484 -0.6974 -0.0720 0.3270 2.2515
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0.0002582 0.01607
## Residual 0.0001756 0.01325
## Number of obs: 36, groups: Plant_ID, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 1.766e-02 1.954e-02 2.600e+01 0.904 0.3745
## GDD_5C 8.139e-07 7.223e-06 2.600e+01 0.113 0.9112
## Plant_ID8987955 1.229e-02 2.788e-02 2.600e+01 0.441 0.6630
## Plant_ID8988752 -8.192e-03 2.788e-02 2.600e+01 -0.294 0.7712
## Plant_ID8988899 5.944e-03 2.788e-02 2.600e+01 0.213 0.8328
## Plant_ID9340742 9.947e-03 2.788e-02 2.600e+01 0.357 0.7241
## GDD_5C:Plant_ID8987955 -3.281e-06 1.030e-05 2.600e+01 -0.318 0.7527
## GDD_5C:Plant_ID8988752 1.807e-05 1.030e-05 2.600e+01 1.754 0.0912 .
## GDD_5C:Plant_ID8988899 -3.662e-07 1.030e-05 2.600e+01 -0.036 0.9719
## GDD_5C:Plant_ID9340742 -5.120e-06 1.030e-05 2.600e+01 -0.497 0.6233
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C P_ID8987 P_ID89887 P_ID89888 P_ID93
## GDD_5C -0.516
## P_ID8987955 -0.701 0.362
## P_ID8988752 -0.701 0.362 0.491
## P_ID8988899 -0.701 0.362 0.491 0.491
## P_ID9340742 -0.701 0.362 0.491 0.491 0.491
## GDD_5C:P_ID8987 0.362 -0.701 -0.524 -0.254 -0.254 -0.254
## GDD_5C:P_ID89887 0.362 -0.701 -0.254 -0.524 -0.254 -0.254
## GDD_5C:P_ID89888 0.362 -0.701 -0.254 -0.254 -0.524 -0.254
## GDD_5C:P_ID9 0.362 -0.701 -0.254 -0.254 -0.254 -0.524
## GDD_5C:P_ID8987 GDD_5C:P_ID89887 GDD_5C:P_ID89888
## GDD_5C
## P_ID8987955
## P_ID8988752
## P_ID8988899
## P_ID9340742
## GDD_5C:P_ID8987
## GDD_5C:P_ID89887 0.492
## GDD_5C:P_ID89888 0.492 0.492
## GDD_5C:P_ID9 0.492 0.492 0.492
# For Populus
lmm_model_populus_specnumber17 <- lmer((1/specnumber) ~ GDD_5C + Plant_ID + (1 |
Plant_ID), data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides"))
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## unable to evaluate scaled gradient
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## Hessian is numerically singular: parameters are not uniquely determined
## Warning in as_lmerModLT(model, devfun): Model may not have converged with 1
## eigenvalue close to zero: 1.8e-10
summary(lmm_model_populus_specnumber17)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: (1/specnumber) ~ GDD_5C + Plant_ID + (1 | Plant_ID)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides")
##
## REML criterion at convergence: -145.5
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.67561 -0.62719 -0.06479 0.35780 2.81462
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 4.465e-05 0.006682
## Residual 1.898e-04 0.013778
## Number of obs: 36, groups: Plant_ID, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 1.508e-02 9.538e-03 3.000e+01 1.581 0.124
## GDD_5C 2.662e-06 3.403e-06 3.000e+01 0.782 0.440
## Plant_ID8987955 7.481e-03 1.184e-02 3.000e+01 0.632 0.532
## Plant_ID8988752 1.776e-02 1.184e-02 3.000e+01 1.500 0.144
## Plant_ID8988899 5.335e-03 1.184e-02 3.000e+01 0.451 0.656
## Plant_ID9340742 2.488e-03 1.184e-02 3.000e+01 0.210 0.835
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C P_ID8987 P_ID89887 P_ID89888
## GDD_5C -0.498
## P_ID8987955 -0.599 -0.013
## P_ID8988752 -0.599 -0.013 0.488
## P_ID8988899 -0.599 -0.013 0.488 0.488
## P_ID9340742 -0.599 -0.013 0.488 0.488 0.488
## optimizer (nloptwrap) convergence code: 0 (OK)
## unable to evaluate scaled gradient
## Hessian is numerically singular: parameters are not uniquely determined
# For Populus
lmm_model_populus_specnumber18 <- lmer(sqrt(specnumber) ~ GDD_5C + Plant_ID + (1 |
Plant_ID), data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides"))
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## unable to evaluate scaled gradient
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## Hessian is numerically singular: parameters are not uniquely determined
## Warning in as_lmerModLT(model, devfun): Model may not have converged with 1
## eigenvalue close to zero: -5.2e-11
summary(lmm_model_populus_specnumber18)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: sqrt(specnumber) ~ GDD_5C + Plant_ID + (1 | Plant_ID)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides")
##
## REML criterion at convergence: 145.2
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.3853 -0.6068 -0.2241 0.6085 1.9507
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 1.261 1.123
## Residual 3.065 1.751
## Number of obs: 36, groups: Plant_ID, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 7.734e+00 1.417e+00 3.000e+01 5.457 6.42e-06 ***
## GDD_5C -2.189e-05 4.324e-04 3.000e+01 -0.051 0.960
## Plant_ID8987955 -1.031e+00 1.829e+00 3.000e+01 -0.564 0.577
## Plant_ID8988752 -1.755e+00 1.829e+00 3.000e+01 -0.960 0.345
## Plant_ID8988899 -6.173e-01 1.829e+00 3.000e+01 -0.338 0.738
## Plant_ID9340742 -6.145e-01 1.829e+00 3.000e+01 -0.336 0.739
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C P_ID8987 P_ID89887 P_ID89888
## GDD_5C -0.426
## P_ID8987955 -0.630 -0.010
## P_ID8988752 -0.630 -0.010 0.492
## P_ID8988899 -0.630 -0.010 0.492 0.492
## P_ID9340742 -0.630 -0.010 0.492 0.492 0.492
## optimizer (nloptwrap) convergence code: 0 (OK)
## unable to evaluate scaled gradient
## Hessian is numerically singular: parameters are not uniquely determined
NOTE: The only models WITHOUT singularity issues
are: - lmm_model_populus_specnumber9 -
lmm_model_populus_specnumber10
#-------------------------------------------------------------------------
## To be sure of my model, let's run formal diagnostics:
#-------------------------------------------------------------------------
# Formal Test of Normality (Shapiro-Wilks)
#-------------------------------------------------------------------------
shapiro.test(residuals(lmm_model_populus_specnumber1)) # p=0.3458 -> Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_populus_specnumber1)
## W = 0.96696, p-value = 0.3484
shapiro.test(residuals(lmm_model_populus_specnumber2)) # p=0.664 -> Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_populus_specnumber2)
## W = 0.97777, p-value = 0.6698
shapiro.test(residuals(lmm_model_populus_specnumber3)) # p=0.4467 -> Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_populus_specnumber3)
## W = 0.97065, p-value = 0.4435
shapiro.test(residuals(lmm_model_populus_specnumber4)) # p=0.008562 -> NOT Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_populus_specnumber4)
## W = 0.91405, p-value = 0.008456
shapiro.test(residuals(lmm_model_populus_specnumber5)) # p=0.01309 -> NOT Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_populus_specnumber5)
## W = 0.92017, p-value = 0.01273
shapiro.test(residuals(lmm_model_populus_specnumber6)) # p=0.6092 -> Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_populus_specnumber6)
## W = 0.97598, p-value = 0.6092
shapiro.test(residuals(lmm_model_populus_specnumber7)) # p=0.5035 -> Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_populus_specnumber7)
## W = 0.97269, p-value = 0.5035
shapiro.test(residuals(lmm_model_populus_specnumber8)) # p=0.9392 -> Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_populus_specnumber8)
## W = 0.98692, p-value = 0.9392
shapiro.test(residuals(lmm_model_populus_specnumber9)) # p=0.8613 -> Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_populus_specnumber9)
## W = 0.98369, p-value = 0.8613
shapiro.test(residuals(lmm_model_populus_specnumber10)) # p=0.00296 -> NOT Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_populus_specnumber10)
## W = 0.89773, p-value = 0.00296
shapiro.test(residuals(lmm_model_populus_specnumber11)) # p=0.02229 -> NOT Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_populus_specnumber11)
## W = 0.92833, p-value = 0.02229
shapiro.test(residuals(lmm_model_populus_specnumber12)) # p=0.6092 -> Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_populus_specnumber12)
## W = 0.97598, p-value = 0.6092
shapiro.test(residuals(lmm_model_populus_specnumber13)) # p=0.0435 -> NOT Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_populus_specnumber13)
## W = 0.93783, p-value = 0.0435
shapiro.test(residuals(lmm_model_populus_specnumber14)) # p=0.0.0001654 -> NOT Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_populus_specnumber14)
## W = 0.84734, p-value = 0.0001654
shapiro.test(residuals(lmm_model_populus_specnumber15)) # p=0.2567 -> NOT Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_populus_specnumber15)
## W = 0.96252, p-value = 0.2567
shapiro.test(residuals(lmm_model_populus_specnumber16)) #NOT Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_populus_specnumber16)
## W = 0.92017, p-value = 0.01273
shapiro.test(residuals(lmm_model_populus_specnumber17))
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_populus_specnumber17)
## W = 0.94853, p-value = 0.09402
shapiro.test(residuals(lmm_model_populus_specnumber18))
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_populus_specnumber18)
## W = 0.9415, p-value = 0.05656
#-------------------------------------------------------------------------
## Check Diagnostic Statistics/Assumptions
#-------------------------------------------------------------------------
check_model(lmm_model_populus_specnumber1, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_populus_specnumber2, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_populus_specnumber3, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_populus_specnumber4, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_populus_specnumber5, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_populus_specnumber6, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_populus_specnumber7, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_populus_specnumber8, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_populus_specnumber9, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_populus_specnumber10, check = c("normality", "vif", "linearity",
"homogeneity", "outliers"))
check_model(lmm_model_populus_specnumber11, check = c("normality", "vif", "linearity",
"homogeneity", "outliers"))
check_model(lmm_model_populus_specnumber12, check = c("normality", "vif", "linearity",
"homogeneity", "outliers"))
check_model(lmm_model_populus_specnumber13, check = c("normality", "vif", "linearity",
"homogeneity", "outliers"))
check_model(lmm_model_populus_specnumber14, check = c("normality", "vif", "linearity",
"homogeneity", "outliers"))
check_model(lmm_model_populus_specnumber15, check = c("normality", "vif", "linearity",
"homogeneity", "outliers"))
check_model(lmm_model_populus_specnumber16, check = c("normality", "vif", "linearity",
"homogeneity", "outliers"))
check_model(lmm_model_populus_specnumber17, check = c("normality", "vif", "linearity",
"homogeneity", "outliers"))
check_model(lmm_model_populus_specnumber18, check = c("normality", "vif", "linearity",
"homogeneity", "outliers"))
NOTE: Hard to determine from diagnostics above alone…
IF NO SINGULARITY: lmm_model_populus_specnumber9 looks
best…
IF SINGULARITY ALLOWED: Can consider
lmm_model_populus_specnumber6,
lmm_model_populus_specnumber8,
lmm_model_populus_specnumber12,
lmm_model_populus_specnumber13 &
lmm_model_populus_specnumber15
#-------------------------------------------------------------------------
## Compare Model Fits with anova():
#-------------------------------------------------------------------------
# Compare 'model' with ANOVA model:
anova(lmm_model_populus_specnumber1, lmm_model_populus_specnumber2, lmm_model_populus_specnumber3,
lmm_model_populus_specnumber4, lmm_model_populus_specnumber5, lmm_model_populus_specnumber6,
lmm_model_populus_specnumber7, lmm_model_populus_specnumber8, lmm_model_populus_specnumber9,
lmm_model_populus_specnumber10, lmm_model_populus_specnumber11, lmm_model_populus_specnumber12,
lmm_model_populus_specnumber13, lmm_model_populus_specnumber14, lmm_model_populus_specnumber15,
lmm_model_populus_specnumber16, lmm_model_populus_specnumber17, lmm_model_populus_specnumber18)
## refitting model(s) with ML (instead of REML)
## Data: subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides")
## Models:
## lmm_model_populus_specnumber8: log(specnumber) ~ GDD_5C + (1 | `Collection-Month`)
## lmm_model_populus_specnumber9: log(specnumber) ~ GDD_5C + (1 | Plant_ID)
## lmm_model_populus_specnumber10: (1/specnumber) ~ GDD_5C + (1 | Plant_ID)
## lmm_model_populus_specnumber6: log(specnumber) ~ GDD_5C + GDD_5C:Plant_ID + (1 | `Collection-Month`)
## lmm_model_populus_specnumber7: log(specnumber) ~ GDD_5C + Plant_ID + (1 | `Collection-Month`)
## lmm_model_populus_specnumber11: specnumber ~ GDD_5C + GDD_5C:Plant_ID + (1 | Plant_ID)
## lmm_model_populus_specnumber12: log(specnumber) ~ GDD_5C + GDD_5C:Plant_ID + (1 | Plant_ID)
## lmm_model_populus_specnumber13: (1/specnumber) ~ GDD_5C + GDD_5C:Plant_ID + (1 | Plant_ID)
## lmm_model_populus_specnumber14: I(specnumber^2) ~ GDD_5C + GDD_5C:Plant_ID + (1 | Plant_ID)
## lmm_model_populus_specnumber15: sqrt(specnumber) ~ GDD_5C + GDD_5C:Plant_ID + (1 | Plant_ID)
## lmm_model_populus_specnumber17: (1/specnumber) ~ GDD_5C + Plant_ID + (1 | Plant_ID)
## lmm_model_populus_specnumber18: sqrt(specnumber) ~ GDD_5C + Plant_ID + (1 | Plant_ID)
## lmm_model_populus_specnumber1: specnumber ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID + (1 | `Collection-Month`)
## lmm_model_populus_specnumber2: sqrt(specnumber) ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID + (1 | `Collection-Month`)
## lmm_model_populus_specnumber3: log(specnumber) ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID + (1 | `Collection-Month`)
## lmm_model_populus_specnumber4: I(specnumber^2) ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID + (1 | `Collection-Month`)
## lmm_model_populus_specnumber5: (1/specnumber) ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID + (1 | `Collection-Month`)
## lmm_model_populus_specnumber16: (1/specnumber) ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID + (1 | Plant_ID)
## npar AIC BIC logLik deviance Chisq
## lmm_model_populus_specnumber8 4 60.59 66.93 -26.30 52.59
## lmm_model_populus_specnumber9 4 60.58 66.92 -26.29 52.58 0.0082
## lmm_model_populus_specnumber10 4 -197.58 -191.25 102.79 -205.58 258.1637
## lmm_model_populus_specnumber6 8 59.15 71.82 -21.57 43.15 0.0000
## lmm_model_populus_specnumber7 8 62.99 75.66 -23.50 46.99 0.0000
## lmm_model_populus_specnumber11 8 343.61 356.27 -163.80 327.61 0.0000
## lmm_model_populus_specnumber12 8 59.15 71.82 -21.57 43.15 284.4580
## lmm_model_populus_specnumber13 8 -202.18 -189.51 109.09 -218.18 261.3243
## lmm_model_populus_specnumber14 8 694.43 707.10 -339.21 678.43 0.0000
## lmm_model_populus_specnumber15 8 149.00 161.66 -66.50 133.00 545.4328
## lmm_model_populus_specnumber17 8 -196.90 -184.23 106.45 -212.90 345.8922
## lmm_model_populus_specnumber18 8 151.92 164.59 -67.96 135.92 0.0000
## lmm_model_populus_specnumber1 12 347.66 366.67 -161.83 323.66 0.0000
## lmm_model_populus_specnumber2 12 153.17 172.17 -64.58 129.17 194.4972
## lmm_model_populus_specnumber3 12 63.57 82.57 -19.79 39.57 89.5941
## lmm_model_populus_specnumber4 12 698.56 717.56 -337.28 674.56 0.0000
## lmm_model_populus_specnumber5 12 -196.85 -177.84 110.42 -220.85 895.4040
## lmm_model_populus_specnumber16 12 -196.85 -177.84 110.42 -220.85 0.0000
## Df Pr(>Chisq)
## lmm_model_populus_specnumber8
## lmm_model_populus_specnumber9 0
## lmm_model_populus_specnumber10 0
## lmm_model_populus_specnumber6 4 1
## lmm_model_populus_specnumber7 0
## lmm_model_populus_specnumber11 0
## lmm_model_populus_specnumber12 0
## lmm_model_populus_specnumber13 0
## lmm_model_populus_specnumber14 0
## lmm_model_populus_specnumber15 0
## lmm_model_populus_specnumber17 0
## lmm_model_populus_specnumber18 0
## lmm_model_populus_specnumber1 4 1
## lmm_model_populus_specnumber2 0
## lmm_model_populus_specnumber3 0
## lmm_model_populus_specnumber4 0
## lmm_model_populus_specnumber5 0
## lmm_model_populus_specnumber16 0
## OVERALL: `lmm_model_populus_specnumber8` and `lmm_model_populus_specnumber9`
## practically have identical values, but they are both the best!
# NOTE: Even though `lmm_model_populus_specnumber13` has lowest AIC an BIC,
# there is a SINGULARITY issues! NOTE: `lmm_model_populus_specnumber10` has
# the next lowest AIC an BIC, so it's our likely choice (despite lacking
# normality, ut important to acknowledge that biological data doesn't always
# conform to normality).
# IF SINGULARITY ALLOWED: `lmm_model_populus_specnumber13` is VERY good! BUT:
# Also consider if singularity allowed: `lmm_model_populus_specnumber6`,
# `lmm_model_populus_specnumber8`, or `lmm_model_populus_specnumber12` (6 & 12
# have identical values)
# ANOVA of LMM model using `car` package.
library(car)
anova_lmm_populus_specnumber1 <- Anova(lmm_model_populus_specnumber1)
anova_lmm_populus_specnumber2 <- Anova(lmm_model_populus_specnumber2)
anova_lmm_populus_specnumber3 <- Anova(lmm_model_populus_specnumber3)
anova_lmm_populus_specnumber4 <- Anova(lmm_model_populus_specnumber4)
anova_lmm_populus_specnumber5 <- Anova(lmm_model_populus_specnumber5)
anova_lmm_populus_specnumber6 <- Anova(lmm_model_populus_specnumber6)
anova_lmm_populus_specnumber7 <- Anova(lmm_model_populus_specnumber7)
anova_lmm_populus_specnumber8 <- Anova(lmm_model_populus_specnumber8)
anova_lmm_populus_specnumber9 <- Anova(lmm_model_populus_specnumber9)
anova_lmm_populus_specnumber10 <- Anova(lmm_model_populus_specnumber10)
anova_lmm_populus_specnumber11 <- Anova(lmm_model_populus_specnumber11)
anova_lmm_populus_specnumber12 <- Anova(lmm_model_populus_specnumber12)
anova_lmm_populus_specnumber13 <- Anova(lmm_model_populus_specnumber13)
anova_lmm_populus_specnumber14 <- Anova(lmm_model_populus_specnumber14)
anova_lmm_populus_specnumber15 <- Anova(lmm_model_populus_specnumber15)
summary(anova_lmm_populus_specnumber1)
## Chisq Df Pr(>Chisq)
## Min. :0.01905 Min. :1.0 Min. :0.3163
## 1st Qu.:1.70494 1st Qu.:2.5 1st Qu.:0.4055
## Median :3.39083 Median :4.0 Median :0.4947
## Mean :2.71296 Mean :3.0 Mean :0.5670
## 3rd Qu.:4.05991 3rd Qu.:4.0 3rd Qu.:0.6924
## Max. :4.72899 Max. :4.0 Max. :0.8902
summary(anova_lmm_populus_specnumber2)
## Chisq Df Pr(>Chisq)
## Min. :0.00268 Min. :1.0 Min. :0.2518
## 1st Qu.:2.10607 1st Qu.:2.5 1st Qu.:0.3151
## Median :4.20946 Median :4.0 Median :0.3784
## Mean :3.19263 Mean :3.0 Mean :0.5296
## 3rd Qu.:4.78761 3rd Qu.:4.0 3rd Qu.:0.6686
## Max. :5.36576 Max. :4.0 Max. :0.9587
summary(anova_lmm_populus_specnumber3)
## Chisq Df Pr(>Chisq)
## Min. :0.08697 Min. :1.0 Min. :0.2027
## 1st Qu.:2.73056 1st Qu.:2.5 1st Qu.:0.2268
## Median :5.37415 Median :4.0 Median :0.2510
## Mean :3.80479 Mean :3.0 Mean :0.4072
## 3rd Qu.:5.66370 3rd Qu.:4.0 3rd Qu.:0.5095
## Max. :5.95324 Max. :4.0 Max. :0.7681
summary(anova_lmm_populus_specnumber4)
## Chisq Df Pr(>Chisq)
## Min. :0.1166 Min. :1.0 Min. :0.4645
## 1st Qu.:1.4348 1st Qu.:2.5 1st Qu.:0.5322
## Median :2.7531 Median :4.0 Median :0.6000
## Mean :2.1529 Mean :3.0 Mean :0.5991
## 3rd Qu.:3.1710 3rd Qu.:4.0 3rd Qu.:0.6663
## Max. :3.5890 Max. :4.0 Max. :0.7327
summary(anova_lmm_populus_specnumber5)
## Chisq Df Pr(>Chisq)
## Min. :0.6615 Min. :1.0 Min. :0.1028
## 1st Qu.:3.5428 1st Qu.:2.5 1st Qu.:0.1362
## Median :6.4241 Median :4.0 Median :0.1696
## Mean :4.9320 Mean :3.0 Mean :0.2295
## 3rd Qu.:7.0673 3rd Qu.:4.0 3rd Qu.:0.2928
## Max. :7.7105 Max. :4.0 Max. :0.4160
summary(anova_lmm_populus_specnumber6)
## Chisq Df Pr(>Chisq)
## Min. :0.1182 Min. :1.00 Min. :0.06115
## 1st Qu.:2.3381 1st Qu.:1.75 1st Qu.:0.22862
## Median :4.5580 Median :2.50 Median :0.39609
## Mean :4.5580 Mean :2.50 Mean :0.39609
## 3rd Qu.:6.7780 3rd Qu.:3.25 3rd Qu.:0.56357
## Max. :8.9979 Max. :4.00 Max. :0.73104
summary(anova_lmm_populus_specnumber7)
## Chisq Df Pr(>Chisq)
## Min. :0.08166 Min. :1.00 Min. :0.2826
## 1st Qu.:1.32265 1st Qu.:1.75 1st Qu.:0.4058
## Median :2.56365 Median :2.50 Median :0.5289
## Mean :2.56365 Mean :2.50 Mean :0.5289
## 3rd Qu.:3.80464 3rd Qu.:3.25 3rd Qu.:0.6520
## Max. :5.04564 Max. :4.00 Max. :0.7751
summary(anova_lmm_populus_specnumber8)
## Chisq Df Pr(>Chisq)
## Min. :0.103 Min. :1 Min. :0.7482
## 1st Qu.:0.103 1st Qu.:1 1st Qu.:0.7482
## Median :0.103 Median :1 Median :0.7482
## Mean :0.103 Mean :1 Mean :0.7482
## 3rd Qu.:0.103 3rd Qu.:1 3rd Qu.:0.7482
## Max. :0.103 Max. :1 Max. :0.7482
summary(anova_lmm_populus_specnumber9)
## Chisq Df Pr(>Chisq)
## Min. :0.1004 Min. :1 Min. :0.7513
## 1st Qu.:0.1004 1st Qu.:1 1st Qu.:0.7513
## Median :0.1004 Median :1 Median :0.7513
## Mean :0.1004 Mean :1 Mean :0.7513
## 3rd Qu.:0.1004 3rd Qu.:1 3rd Qu.:0.7513
## Max. :0.1004 Max. :1 Max. :0.7513
summary(anova_lmm_populus_specnumber10)
## Chisq Df Pr(>Chisq)
## Min. :0.6475 Min. :1 Min. :0.421
## 1st Qu.:0.6475 1st Qu.:1 1st Qu.:0.421
## Median :0.6475 Median :1 Median :0.421
## Mean :0.6475 Mean :1 Mean :0.421
## 3rd Qu.:0.6475 3rd Qu.:1 3rd Qu.:0.421
## Max. :0.6475 Max. :1 Max. :0.421
summary(anova_lmm_populus_specnumber11)
## Chisq Df Pr(>Chisq)
## Min. :0.01018 Min. :1.00 Min. :0.2592
## 1st Qu.:1.32902 1st Qu.:1.75 1st Qu.:0.4243
## Median :2.64786 Median :2.50 Median :0.5894
## Mean :2.64786 Mean :2.50 Mean :0.5894
## 3rd Qu.:3.96670 3rd Qu.:3.25 3rd Qu.:0.7545
## Max. :5.28554 Max. :4.00 Max. :0.9196
summary(anova_lmm_populus_specnumber12)
## Chisq Df Pr(>Chisq)
## Min. :0.1182 Min. :1.00 Min. :0.06115
## 1st Qu.:2.3381 1st Qu.:1.75 1st Qu.:0.22862
## Median :4.5580 Median :2.50 Median :0.39609
## Mean :4.5580 Mean :2.50 Mean :0.39609
## 3rd Qu.:6.7780 3rd Qu.:3.25 3rd Qu.:0.56357
## Max. :8.9979 Max. :4.00 Max. :0.73104
summary(anova_lmm_populus_specnumber13)
## Chisq Df Pr(>Chisq)
## Min. : 0.785 Min. :1.00 Min. :0.01127
## 1st Qu.: 3.839 1st Qu.:1.75 1st Qu.:0.10236
## Median : 6.893 Median :2.50 Median :0.19344
## Mean : 6.893 Mean :2.50 Mean :0.19344
## 3rd Qu.: 9.946 3rd Qu.:3.25 3rd Qu.:0.28453
## Max. :13.000 Max. :4.00 Max. :0.37561
summary(anova_lmm_populus_specnumber14)
## Chisq Df Pr(>Chisq)
## Min. :0.09482 Min. :1.00 Min. :0.4757
## 1st Qu.:0.94967 1st Qu.:1.75 1st Qu.:0.5463
## Median :1.80451 Median :2.50 Median :0.6169
## Mean :1.80451 Mean :2.50 Mean :0.6169
## 3rd Qu.:2.65936 3rd Qu.:3.25 3rd Qu.:0.6875
## Max. :3.51420 Max. :4.00 Max. :0.7581
summary(anova_lmm_populus_specnumber15)
## Chisq Df Pr(>Chisq)
## Min. :0.008715 Min. :1.00 Min. :0.1409
## 1st Qu.:1.733069 1st Qu.:1.75 1st Qu.:0.3371
## Median :3.457423 Median :2.50 Median :0.5333
## Mean :3.457423 Mean :2.50 Mean :0.5333
## 3rd Qu.:5.181777 3rd Qu.:3.25 3rd Qu.:0.7295
## Max. :6.906131 Max. :4.00 Max. :0.9256
# `lmm_model_populus_specnumber13` mostly, then `lmm_model_populus_specnumber6`
# and `lmm_model_populus_specnumber12` have singularity issues!
################################################################################ CHOICE:`lmm_model_populus_specnumber10`
lmm_model_populus_specnumber10 <- lmer((1/specnumber) ~ GDD_5C + (1 | Plant_ID),
data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides"))
summary(lmm_model_populus_specnumber10)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: (1/specnumber) ~ GDD_5C + (1 | Plant_ID)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides")
##
## REML criterion at convergence: -172.4
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.2654 -0.7350 -0.0928 0.2893 3.2750
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 2.072e-05 0.004552
## Residual 1.898e-04 0.013775
## Number of obs: 36, groups: Plant_ID, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 2.148e-02 5.756e-03 2.678e+01 3.733 0.000903 ***
## GDD_5C 2.737e-06 3.401e-06 3.005e+01 0.805 0.427322
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## GDD_5C -0.846
################################################################################ IF
################################################################################ SINGULARITIES
################################################################################ ALLOWED;
################################################################################ ALTERNATE
################################################################################ CHOICE:
################################################################################ `lmm_model_populus_specnumber13`
lmm_model_populus_specnumber13 <- lmer((1/specnumber) ~ GDD_5C + GDD_5C:Plant_ID +
(1 | Plant_ID), data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides"))
## boundary (singular) fit: see help('isSingular')
summary(lmm_model_populus_specnumber13)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: (1/specnumber) ~ GDD_5C + GDD_5C:Plant_ID + (1 | Plant_ID)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides")
##
## REML criterion at convergence: -90.9
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.46560 -0.67879 -0.01366 0.35404 2.45286
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0.0000000 0.0000
## Residual 0.0001639 0.0128
## Number of obs: 36, groups: Plant_ID, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 2.157e-02 5.004e-03 3.000e+01 4.311 0.000162 ***
## GDD_5C -1.491e-06 4.163e-06 3.000e+01 -0.358 0.722738
## GDD_5C:Plant_ID8987955 3.773e-06 4.227e-06 3.000e+01 0.893 0.379155
## GDD_5C:Plant_ID8988752 1.351e-05 4.227e-06 3.000e+01 3.196 0.003270 **
## GDD_5C:Plant_ID8988899 3.090e-06 4.227e-06 3.000e+01 0.731 0.470462
## GDD_5C:Plant_ID9340742 6.054e-07 4.227e-06 3.000e+01 0.143 0.887078
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C GDD_5C:P_ID8987 GDD_5C:P_ID89887
## GDD_5C -0.708
## GDD_5C:P_ID8987 0.026 -0.510
## GDD_5C:P_ID89887 0.026 -0.510 0.484
## GDD_5C:P_ID89888 0.026 -0.510 0.484 0.484
## GDD_5C:P_ID9 0.026 -0.510 0.484 0.484
## GDD_5C:P_ID89888
## GDD_5C
## GDD_5C:P_ID8987
## GDD_5C:P_ID89887
## GDD_5C:P_ID89888
## GDD_5C:P_ID9 0.484
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
## NOTE: This is why we likely DON'T choose the one with SINGULARITY... Notice
## that here, the R^2 for the Random Effect is 0, so NO VARIANCE in our Random
## Effect (corroborated by our ChiSq values and >Pr(ChiSq) being oddly all
## similar, and our R2c and R2m being the same too...):
library(rsq)
rsq.lmm(lmm_model_populus_specnumber13)
## $model
## [1] 0.314838
##
## $fixed
## [1] 0.314838
##
## $random
## [1] 0
# $model [1] 0.314838
# $fixed [1] 0.314838
# $random -> NOTE NO VARIANCE! [1] 0
#--------------------------------------------------------------
## Conditional & Marginal R^2 for `GDD_5C` in Populus
#--------------------------------------------------------------
# Calculate marginal R-squared for `GDD_5C`
populus_specnumber_r_squared <- r.squaredGLMM(lmm_model_populus_specnumber9, mu0 = "fixed")
print(populus_specnumber_r_squared)
## R2m R2c
## [1,] 0.002756337 0.03969465
populus_specnumber_r_squared <- r.squaredGLMM(lmm_model_populus_specnumber10, mu0 = "fixed")
print(populus_specnumber_r_squared)
## R2m R2c
## [1,] 0.01641116 0.1132342
# OR
# Calculate marginal R-squared for `GDD_5C`
populus_specnumber_r_squared <- r.squaredGLMM(lmm_model_populus_specnumber13, mu0 = "fixed")
print(populus_specnumber_r_squared)
## R2m R2c
## [1,] 0.2825702 0.2825702
# *NOTE: Will have to do marginal/conditional R^2 for GDD_5C:Plant_ID too!!!
# *NOTE: Odd to have both conditional and marginal R^2 be same...
# install.packages('urca')
library(urca)
# Perform KPSS test
kpss_populus_specnumber <- ur.kpss(populus_data$specnumber)
kpss_populus_specnumber <- ur.kpss(asv_scaled_noPlants_Phen_filt_LMM$specnumber[asv_scaled_noPlants_Phen_filt_LMM$Species ==
"Populus_tremuloides"])
# summary of KPSS Test
summary(kpss_populus_specnumber)
##
## #######################
## # KPSS Unit Root Test #
## #######################
##
## Test is of type: mu with 3 lags.
##
## Value of test-statistic is: 0.0894
##
## Critical value for a significance level of:
## 10pct 5pct 2.5pct 1pct
## critical values 0.347 0.463 0.574 0.739
# ASV richness in Populus is STATIONARY!
# For Betula
lmm_model_betula_shannon1 <- lmer(alphaDiv ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID +
(1 | `Collection-Month`), data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species ==
"Betula_populifolia"))
## boundary (singular) fit: see help('isSingular')
summary(lmm_model_betula_shannon1)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## alphaDiv ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID + (1 | `Collection-Month`)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia")
##
## REML criterion at convergence: 131.3
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.37579 -0.48022 -0.04077 0.63885 1.44018
##
## Random effects:
## Groups Name Variance Std.Dev.
## Collection-Month (Intercept) 0.0000 0.0000
## Residual 0.3777 0.6145
## Number of obs: 35, groups: Collection-Month, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 2.9670799 0.5428534 25.0000000 5.466 1.12e-05 ***
## GDD_5C -0.0002257 0.0003405 25.0000000 -0.663 0.514
## Plant_ID8553606 -0.4222956 0.7677106 25.0000000 -0.550 0.587
## Plant_ID8553762 -0.2340720 0.7677106 25.0000000 -0.305 0.763
## Plant_ID8553879 -1.2257085 0.7677106 25.0000000 -1.597 0.123
## Plant_ID8554325 -0.3842965 0.7677106 25.0000000 -0.501 0.621
## GDD_5C:Plant_ID8553606 0.0003770 0.0004816 25.0000000 0.783 0.441
## GDD_5C:Plant_ID8553762 0.0001788 0.0004816 25.0000000 0.371 0.714
## GDD_5C:Plant_ID8553879 0.0003234 0.0004816 25.0000000 0.671 0.508
## GDD_5C:Plant_ID8554325 0.0001516 0.0004816 25.0000000 0.315 0.756
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C P_ID85536 P_ID85537 P_ID85538 P_ID8554
## GDD_5C -0.904
## P_ID8553606 -0.707 0.639
## P_ID8553762 -0.707 0.639 0.500
## P_ID8553879 -0.707 0.639 0.500 0.500
## P_ID8554325 -0.707 0.639 0.500 0.500 0.500
## GDD_5C:P_ID85536 0.639 -0.707 -0.904 -0.452 -0.452 -0.452
## GDD_5C:P_ID85537 0.639 -0.707 -0.452 -0.904 -0.452 -0.452
## GDD_5C:P_ID85538 0.639 -0.707 -0.452 -0.452 -0.904 -0.452
## GDD_5C:P_ID8554 0.639 -0.707 -0.452 -0.452 -0.452 -0.904
## GDD_5C:P_ID85536 GDD_5C:P_ID85537 GDD_5C:P_ID85538
## GDD_5C
## P_ID8553606
## P_ID8553762
## P_ID8553879
## P_ID8554325
## GDD_5C:P_ID85536
## GDD_5C:P_ID85537 0.500
## GDD_5C:P_ID85538 0.500 0.500
## GDD_5C:P_ID8554 0.500 0.500 0.500
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
# For Betula
lmm_model_betula_shannon2 <- lmer(sqrt(alphaDiv) ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID +
(1 | `Collection-Month`), data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species ==
"Betula_populifolia"))
## boundary (singular) fit: see help('isSingular')
summary(lmm_model_betula_shannon2)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## sqrt(alphaDiv) ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID + (1 | `Collection-Month`)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia")
##
## REML criterion at convergence: 76
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.48775 -0.50825 -0.00299 0.63049 1.34422
##
## Random effects:
## Groups Name Variance Std.Dev.
## Collection-Month (Intercept) 0.00000 0.0000
## Residual 0.04134 0.2033
## Number of obs: 35, groups: Collection-Month, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 1.728e+00 1.796e-01 2.500e+01 9.619 6.98e-10 ***
## GDD_5C -7.556e-05 1.127e-04 2.500e+01 -0.671 0.509
## Plant_ID8553606 -1.420e-01 2.540e-01 2.500e+01 -0.559 0.581
## Plant_ID8553762 -5.684e-02 2.540e-01 2.500e+01 -0.224 0.825
## Plant_ID8553879 -4.163e-01 2.540e-01 2.500e+01 -1.639 0.114
## Plant_ID8554325 -1.421e-01 2.540e-01 2.500e+01 -0.560 0.581
## GDD_5C:Plant_ID8553606 1.249e-04 1.593e-04 2.500e+01 0.784 0.440
## GDD_5C:Plant_ID8553762 3.722e-05 1.593e-04 2.500e+01 0.234 0.817
## GDD_5C:Plant_ID8553879 1.108e-04 1.593e-04 2.500e+01 0.696 0.493
## GDD_5C:Plant_ID8554325 6.060e-05 1.593e-04 2.500e+01 0.380 0.707
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C P_ID85536 P_ID85537 P_ID85538 P_ID8554
## GDD_5C -0.904
## P_ID8553606 -0.707 0.639
## P_ID8553762 -0.707 0.639 0.500
## P_ID8553879 -0.707 0.639 0.500 0.500
## P_ID8554325 -0.707 0.639 0.500 0.500 0.500
## GDD_5C:P_ID85536 0.639 -0.707 -0.904 -0.452 -0.452 -0.452
## GDD_5C:P_ID85537 0.639 -0.707 -0.452 -0.904 -0.452 -0.452
## GDD_5C:P_ID85538 0.639 -0.707 -0.452 -0.452 -0.904 -0.452
## GDD_5C:P_ID8554 0.639 -0.707 -0.452 -0.452 -0.452 -0.904
## GDD_5C:P_ID85536 GDD_5C:P_ID85537 GDD_5C:P_ID85538
## GDD_5C
## P_ID8553606
## P_ID8553762
## P_ID8553879
## P_ID8554325
## GDD_5C:P_ID85536
## GDD_5C:P_ID85537 0.500
## GDD_5C:P_ID85538 0.500 0.500
## GDD_5C:P_ID8554 0.500 0.500 0.500
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
# For Betula
lmm_model_betula_shannon3 <- lmer(I(alphaDiv^2) ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID +
(1 | `Collection-Month`), data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species ==
"Betula_populifolia"))
## boundary (singular) fit: see help('isSingular')
summary(lmm_model_betula_shannon3)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## I(alphaDiv^2) ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID + (1 | `Collection-Month`)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia")
##
## REML criterion at convergence: 210.6
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.1578 -0.4646 -0.1149 0.6208 1.7758
##
## Random effects:
## Groups Name Variance Std.Dev.
## Collection-Month (Intercept) 0.000 0
## Residual 9.001 3
## Number of obs: 35, groups: Collection-Month, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 8.6548452 2.6501821 25.0000000 3.266 0.00316 **
## GDD_5C -0.0010126 0.0016624 25.0000000 -0.609 0.54796
## Plant_ID8553606 -1.8275411 3.7479235 25.0000000 -0.488 0.63007
## Plant_ID8553762 -1.6423735 3.7479235 25.0000000 -0.438 0.66500
## Plant_ID8553879 -5.4624408 3.7479235 25.0000000 -1.457 0.15744
## Plant_ID8554325 -1.3245459 3.7479235 25.0000000 -0.353 0.72675
## GDD_5C:Plant_ID8553606 0.0017150 0.0023510 25.0000000 0.729 0.47249
## GDD_5C:Plant_ID8553762 0.0014034 0.0023510 25.0000000 0.597 0.55591
## GDD_5C:Plant_ID8553879 0.0013894 0.0023510 25.0000000 0.591 0.55984
## GDD_5C:Plant_ID8554325 0.0003907 0.0023510 25.0000000 0.166 0.86936
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C P_ID85536 P_ID85537 P_ID85538 P_ID8554
## GDD_5C -0.904
## P_ID8553606 -0.707 0.639
## P_ID8553762 -0.707 0.639 0.500
## P_ID8553879 -0.707 0.639 0.500 0.500
## P_ID8554325 -0.707 0.639 0.500 0.500 0.500
## GDD_5C:P_ID85536 0.639 -0.707 -0.904 -0.452 -0.452 -0.452
## GDD_5C:P_ID85537 0.639 -0.707 -0.452 -0.904 -0.452 -0.452
## GDD_5C:P_ID85538 0.639 -0.707 -0.452 -0.452 -0.904 -0.452
## GDD_5C:P_ID8554 0.639 -0.707 -0.452 -0.452 -0.452 -0.904
## GDD_5C:P_ID85536 GDD_5C:P_ID85537 GDD_5C:P_ID85538
## GDD_5C
## P_ID8553606
## P_ID8553762
## P_ID8553879
## P_ID8554325
## GDD_5C:P_ID85536
## GDD_5C:P_ID85537 0.500
## GDD_5C:P_ID85538 0.500 0.500
## GDD_5C:P_ID8554 0.500 0.500 0.500
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
# For Betula
lmm_model_betula_shannon4 <- lmer(log(alphaDiv) ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID +
(1 | `Collection-Month`), data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species ==
"Betula_populifolia"))
## boundary (singular) fit: see help('isSingular')
summary(lmm_model_betula_shannon4)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## log(alphaDiv) ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID + (1 | `Collection-Month`)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia")
##
## REML criterion at convergence: 91.3
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.59564 -0.49588 0.01097 0.61611 1.30982
##
## Random effects:
## Groups Name Variance Std.Dev.
## Collection-Month (Intercept) 0.00000 0.000
## Residual 0.07616 0.276
## Number of obs: 35, groups: Collection-Month, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 1.101e+00 2.438e-01 2.500e+01 4.515 0.000131 ***
## GDD_5C -1.014e-04 1.529e-04 2.500e+01 -0.663 0.513342
## Plant_ID8553606 -1.900e-01 3.447e-01 2.500e+01 -0.551 0.586364
## Plant_ID8553762 -4.682e-02 3.447e-01 2.500e+01 -0.136 0.893069
## Plant_ID8553879 -5.710e-01 3.447e-01 2.500e+01 -1.656 0.110171
## Plant_ID8554325 -2.078e-01 3.447e-01 2.500e+01 -0.603 0.552117
## GDD_5C:Plant_ID8553606 1.656e-04 2.163e-04 2.500e+01 0.766 0.451061
## GDD_5C:Plant_ID8553762 1.811e-05 2.163e-04 2.500e+01 0.084 0.933925
## GDD_5C:Plant_ID8553879 1.524e-04 2.163e-04 2.500e+01 0.705 0.487364
## GDD_5C:Plant_ID8554325 9.389e-05 2.163e-04 2.500e+01 0.434 0.667889
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C P_ID85536 P_ID85537 P_ID85538 P_ID8554
## GDD_5C -0.904
## P_ID8553606 -0.707 0.639
## P_ID8553762 -0.707 0.639 0.500
## P_ID8553879 -0.707 0.639 0.500 0.500
## P_ID8554325 -0.707 0.639 0.500 0.500 0.500
## GDD_5C:P_ID85536 0.639 -0.707 -0.904 -0.452 -0.452 -0.452
## GDD_5C:P_ID85537 0.639 -0.707 -0.452 -0.904 -0.452 -0.452
## GDD_5C:P_ID85538 0.639 -0.707 -0.452 -0.452 -0.904 -0.452
## GDD_5C:P_ID8554 0.639 -0.707 -0.452 -0.452 -0.452 -0.904
## GDD_5C:P_ID85536 GDD_5C:P_ID85537 GDD_5C:P_ID85538
## GDD_5C
## P_ID8553606
## P_ID8553762
## P_ID8553879
## P_ID8554325
## GDD_5C:P_ID85536
## GDD_5C:P_ID85537 0.500
## GDD_5C:P_ID85538 0.500 0.500
## GDD_5C:P_ID8554 0.500 0.500 0.500
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
# For Betula
lmm_model_betula_shannon5 <- lmer((1/alphaDiv) ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID +
(1 | `Collection-Month`), data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species ==
"Betula_populifolia"))
## boundary (singular) fit: see help('isSingular')
summary(lmm_model_betula_shannon5)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## (1/alphaDiv) ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID + (1 | `Collection-Month`)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia")
##
## REML criterion at convergence: 56.6
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.24849 -0.70570 -0.00214 0.39900 2.78038
##
## Random effects:
## Groups Name Variance Std.Dev.
## Collection-Month (Intercept) 0.00000 0.0000
## Residual 0.01902 0.1379
## Number of obs: 35, groups: Collection-Month, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 3.260e-01 1.218e-01 2.500e+01 2.676 0.013 *
## GDD_5C 4.597e-05 7.642e-05 2.500e+01 0.601 0.553
## Plant_ID8553606 8.450e-02 1.723e-01 2.500e+01 0.490 0.628
## Plant_ID8553762 -7.960e-03 1.723e-01 2.500e+01 -0.046 0.964
## Plant_ID8553879 2.769e-01 1.723e-01 2.500e+01 1.607 0.121
## Plant_ID8554325 1.087e-01 1.723e-01 2.500e+01 0.631 0.534
## GDD_5C:Plant_ID8553606 -7.301e-05 1.081e-04 2.500e+01 -0.676 0.506
## GDD_5C:Plant_ID8553762 2.474e-05 1.081e-04 2.500e+01 0.229 0.821
## GDD_5C:Plant_ID8553879 -7.271e-05 1.081e-04 2.500e+01 -0.673 0.507
## GDD_5C:Plant_ID8554325 -5.326e-05 1.081e-04 2.500e+01 -0.493 0.626
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C P_ID85536 P_ID85537 P_ID85538 P_ID8554
## GDD_5C -0.904
## P_ID8553606 -0.707 0.639
## P_ID8553762 -0.707 0.639 0.500
## P_ID8553879 -0.707 0.639 0.500 0.500
## P_ID8554325 -0.707 0.639 0.500 0.500 0.500
## GDD_5C:P_ID85536 0.639 -0.707 -0.904 -0.452 -0.452 -0.452
## GDD_5C:P_ID85537 0.639 -0.707 -0.452 -0.904 -0.452 -0.452
## GDD_5C:P_ID85538 0.639 -0.707 -0.452 -0.452 -0.904 -0.452
## GDD_5C:P_ID8554 0.639 -0.707 -0.452 -0.452 -0.452 -0.904
## GDD_5C:P_ID85536 GDD_5C:P_ID85537 GDD_5C:P_ID85538
## GDD_5C
## P_ID8553606
## P_ID8553762
## P_ID8553879
## P_ID8554325
## GDD_5C:P_ID85536
## GDD_5C:P_ID85537 0.500
## GDD_5C:P_ID85538 0.500 0.500
## GDD_5C:P_ID8554 0.500 0.500 0.500
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
# For Betula
lmm_model_betula_shannon6 <- lmer(I(alphaDiv^2) ~ GDD_5C + GDD_5C:Plant_ID + (1 |
`Collection-Month`), data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species ==
"Betula_populifolia"))
## boundary (singular) fit: see help('isSingular')
summary(lmm_model_betula_shannon6)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: I(alphaDiv^2) ~ GDD_5C + GDD_5C:Plant_ID + (1 | `Collection-Month`)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia")
##
## REML criterion at convergence: 229.7
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.25142 -0.60107 -0.07831 0.53159 1.85770
##
## Random effects:
## Groups Name Variance Std.Dev.
## Collection-Month (Intercept) 0.000 0.000
## Residual 8.493 2.914
## Number of obs: 35, groups: Collection-Month, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 6.6034649 1.1512386 29.0000000 5.736 3.29e-06 ***
## GDD_5C 0.0001505 0.0009505 29.0000000 0.158 0.8753
## GDD_5C:Plant_ID8553606 0.0006789 0.0009771 29.0000000 0.695 0.4928
## GDD_5C:Plant_ID8553762 0.0004723 0.0009771 29.0000000 0.483 0.6325
## GDD_5C:Plant_ID8553879 -0.0017076 0.0009771 29.0000000 -1.748 0.0911 .
## GDD_5C:Plant_ID8554325 -0.0003603 0.0009771 29.0000000 -0.369 0.7150
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C GDD_5C:P_ID85536 GDD_5C:P_ID85537
## GDD_5C -0.687
## GDD_5C:P_ID85536 0.000 -0.514
## GDD_5C:P_ID85537 0.000 -0.514 0.500
## GDD_5C:P_ID85538 0.000 -0.514 0.500 0.500
## GDD_5C:P_ID8554 0.000 -0.514 0.500 0.500
## GDD_5C:P_ID85538
## GDD_5C
## GDD_5C:P_ID85536
## GDD_5C:P_ID85537
## GDD_5C:P_ID85538
## GDD_5C:P_ID8554 0.500
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
# For Betula
lmm_model_betula_shannon7 <- lmer(sqrt(alphaDiv) ~ GDD_5C + GDD_5C:Plant_ID + (1 |
`Collection-Month`), data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species ==
"Betula_populifolia"))
## boundary (singular) fit: see help('isSingular')
summary(lmm_model_betula_shannon7)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: sqrt(alphaDiv) ~ GDD_5C + GDD_5C:Plant_ID + (1 | `Collection-Month`)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia")
##
## REML criterion at convergence: 74.4
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.62491 -0.55306 0.05802 0.66978 1.30283
##
## Random effects:
## Groups Name Variance Std.Dev.
## Collection-Month (Intercept) 0.00000 0.0000
## Residual 0.04015 0.2004
## Number of obs: 35, groups: Collection-Month, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 1.576e+00 7.916e-02 2.900e+01 19.911 <2e-16 ***
## GDD_5C 1.030e-05 6.535e-05 2.900e+01 0.158 0.8759
## GDD_5C:Plant_ID8553606 4.440e-05 6.719e-05 2.900e+01 0.661 0.5139
## GDD_5C:Plant_ID8553762 5.001e-06 6.719e-05 2.900e+01 0.074 0.9412
## GDD_5C:Plant_ID8553879 -1.252e-04 6.719e-05 2.900e+01 -1.863 0.0726 .
## GDD_5C:Plant_ID8554325 -1.997e-05 6.719e-05 2.900e+01 -0.297 0.7684
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C GDD_5C:P_ID85536 GDD_5C:P_ID85537
## GDD_5C -0.687
## GDD_5C:P_ID85536 0.000 -0.514
## GDD_5C:P_ID85537 0.000 -0.514 0.500
## GDD_5C:P_ID85538 0.000 -0.514 0.500 0.500
## GDD_5C:P_ID8554 0.000 -0.514 0.500 0.500
## GDD_5C:P_ID85538
## GDD_5C
## GDD_5C:P_ID85536
## GDD_5C:P_ID85537
## GDD_5C:P_ID85538
## GDD_5C:P_ID8554 0.500
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
# For Betula
lmm_model_betula_shannon8 <- lmer(alphaDiv ~ GDD_5C + (1 | Plant_ID), data = subset(asv_scaled_noPlants_Phen_filt_LMM,
Species == "Betula_populifolia"))
summary(lmm_model_betula_shannon8)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: alphaDiv ~ GDD_5C + (1 | Plant_ID)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia")
##
## REML criterion at convergence: 81.6
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.43379 -0.60702 0.07639 0.63791 1.60770
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0.07653 0.2766
## Residual 0.33559 0.5793
## Number of obs: 35, groups: Plant_ID, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 2.514e+00 2.601e-01 2.101e+01 9.663 3.51e-09 ***
## GDD_5C -1.956e-05 1.435e-04 2.900e+01 -0.136 0.893
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## GDD_5C -0.795
# For Betula
lmm_model_betula_shannon9 <- lmer(I(alphaDiv^2) ~ GDD_5C + (1 | Plant_ID), data = subset(asv_scaled_noPlants_Phen_filt_LMM,
Species == "Betula_populifolia"))
summary(lmm_model_betula_shannon9)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: I(alphaDiv^2) ~ GDD_5C + (1 | Plant_ID)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia")
##
## REML criterion at convergence: 186
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.03435 -0.66065 -0.00225 0.50891 1.97850
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 1.623 1.274
## Residual 8.006 2.830
## Number of obs: 35, groups: Plant_ID, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 6.603e+00 1.255e+00 2.203e+01 5.263 2.78e-05 ***
## GDD_5C -3.287e-05 7.012e-04 2.900e+01 -0.047 0.963
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## GDD_5C -0.805
# For Betula
lmm_model_betula_shannon10 <- lmer(sqrt(alphaDiv) ~ GDD_5C + (1 | Plant_ID), data = subset(asv_scaled_noPlants_Phen_filt_LMM,
Species == "Betula_populifolia"))
summary(lmm_model_betula_shannon10)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: sqrt(alphaDiv) ~ GDD_5C + (1 | Plant_ID)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia")
##
## REML criterion at convergence: 8.7
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.6388 -0.5592 0.1050 0.6907 1.4433
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0.008483 0.0921
## Residual 0.036835 0.1919
## Number of obs: 35, groups: Plant_ID, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 1.576e+00 8.628e-02 2.092e+01 18.266 2.47e-14 ***
## GDD_5C -8.851e-06 4.756e-05 2.900e+01 -0.186 0.854
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## GDD_5C -0.794
# For Betula
lmm_model_betula_shannon11 <- lmer((1/alphaDiv) ~ GDD_5C + (1 | Plant_ID), data = subset(asv_scaled_noPlants_Phen_filt_LMM,
Species == "Betula_populifolia"))
summary(lmm_model_betula_shannon11)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: (1/alphaDiv) ~ GDD_5C + (1 | Plant_ID)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia")
##
## REML criterion at convergence: -16.7
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.1072 -0.6960 -0.1884 0.3618 3.1850
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0.003262 0.05712
## Residual 0.017295 0.13151
## Number of obs: 35, groups: Plant_ID, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 4.184e-01 5.789e-02 2.263e+01 7.228 2.58e-07 ***
## GDD_5C 1.112e-05 3.259e-05 2.900e+01 0.341 0.735
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## GDD_5C -0.811
# For Betula
lmm_model_betula_shannon12 <- lmer(log(alphaDiv) ~ GDD_5C + (1 | Plant_ID), data = subset(asv_scaled_noPlants_Phen_filt_LMM,
Species == "Betula_populifolia"))
summary(lmm_model_betula_shannon12)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: log(alphaDiv) ~ GDD_5C + (1 | Plant_ID)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia")
##
## REML criterion at convergence: 29
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.8371 -0.5007 0.1294 0.7307 1.3279
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0.01528 0.1236
## Residual 0.06822 0.2612
## Number of obs: 35, groups: Plant_ID, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 8.975e-01 1.171e-01 2.116e+01 7.667 1.54e-07 ***
## GDD_5C -1.539e-05 6.472e-05 2.900e+01 -0.238 0.814
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## GDD_5C -0.797
# For Populus
lmm_model_betula_shannon13 <- lmer(alphaDiv ~ GDD_5C + GDD_5C:Plant_ID + (1 | Plant_ID),
data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia"))
## boundary (singular) fit: see help('isSingular')
summary(lmm_model_betula_shannon13)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: alphaDiv ~ GDD_5C + GDD_5C:Plant_ID + (1 | Plant_ID)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia")
##
## REML criterion at convergence: 138.3
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.4996 -0.5813 -0.0029 0.6035 1.4879
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0.0000 0.0000
## Residual 0.3634 0.6028
## Number of obs: 35, groups: Plant_ID, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 2.514e+00 2.381e-01 2.900e+01 10.556 1.91e-11 ***
## GDD_5C 3.129e-05 1.966e-04 2.900e+01 0.159 0.8747
## GDD_5C:Plant_ID8553606 1.375e-04 2.021e-04 2.900e+01 0.680 0.5016
## GDD_5C:Plant_ID8553762 4.609e-05 2.021e-04 2.900e+01 0.228 0.8212
## GDD_5C:Plant_ID8553879 -3.716e-04 2.021e-04 2.900e+01 -1.838 0.0763 .
## GDD_5C:Plant_ID8554325 -6.631e-05 2.021e-04 2.900e+01 -0.328 0.7452
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C GDD_5C:P_ID85536 GDD_5C:P_ID85537
## GDD_5C -0.687
## GDD_5C:P_ID85536 0.000 -0.514
## GDD_5C:P_ID85537 0.000 -0.514 0.500
## GDD_5C:P_ID85538 0.000 -0.514 0.500 0.500
## GDD_5C:P_ID8554 0.000 -0.514 0.500 0.500
## GDD_5C:P_ID85538
## GDD_5C
## GDD_5C:P_ID85536
## GDD_5C:P_ID85537
## GDD_5C:P_ID85538
## GDD_5C:P_ID8554 0.500
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
# For Populus
lmm_model_betula_shannon14 <- lmer(log(alphaDiv) ~ GDD_5C + GDD_5C:Plant_ID + (1 |
Plant_ID), data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia"))
## boundary (singular) fit: see help('isSingular')
summary(lmm_model_betula_shannon14)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: log(alphaDiv) ~ GDD_5C + GDD_5C:Plant_ID + (1 | Plant_ID)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia")
##
## REML criterion at convergence: 92.3
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.7457 -0.5120 0.1302 0.7313 1.2498
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 4.758e-22 2.181e-11
## Residual 7.455e-02 2.730e-01
## Number of obs: 35, groups: Plant_ID, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 8.975e-01 1.079e-01 2.900e+01 8.321 3.58e-09 ***
## GDD_5C 1.377e-05 8.905e-05 2.900e+01 0.155 0.8782
## GDD_5C:Plant_ID8553606 5.783e-05 9.155e-05 2.900e+01 0.632 0.5325
## GDD_5C:Plant_ID8553762 -8.432e-06 9.155e-05 2.900e+01 -0.092 0.9272
## GDD_5C:Plant_ID8553879 -1.713e-04 9.155e-05 2.900e+01 -1.871 0.0715 .
## GDD_5C:Plant_ID8554325 -2.392e-05 9.155e-05 2.900e+01 -0.261 0.7957
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C GDD_5C:P_ID85536 GDD_5C:P_ID85537
## GDD_5C -0.687
## GDD_5C:P_ID85536 0.000 -0.514
## GDD_5C:P_ID85537 0.000 -0.514 0.500
## GDD_5C:P_ID85538 0.000 -0.514 0.500 0.500
## GDD_5C:P_ID8554 0.000 -0.514 0.500 0.500
## GDD_5C:P_ID85538
## GDD_5C
## GDD_5C:P_ID85536
## GDD_5C:P_ID85537
## GDD_5C:P_ID85538
## GDD_5C:P_ID8554 0.500
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
# For Betula
lmm_model_betula_shannon15 <- lmer((1/alphaDiv) ~ GDD_5C + GDD_5C:Plant_ID + (1 |
Plant_ID), data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia"))
## boundary (singular) fit: see help('isSingular')
summary(lmm_model_betula_shannon15)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: (1/alphaDiv) ~ GDD_5C + GDD_5C:Plant_ID + (1 | Plant_ID)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia")
##
## REML criterion at convergence: 52.3
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.2838 -0.6839 -0.2419 0.3957 2.9577
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0.00000 0.0000
## Residual 0.01874 0.1369
## Number of obs: 35, groups: Plant_ID, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 4.184e-01 5.408e-02 2.900e+01 7.738 1.56e-08 ***
## GDD_5C -6.439e-06 4.465e-05 2.900e+01 -0.144 0.8863
## GDD_5C:Plant_ID8553606 -2.510e-05 4.590e-05 2.900e+01 -0.547 0.5886
## GDD_5C:Plant_ID8553762 2.023e-05 4.590e-05 2.900e+01 0.441 0.6627
## GDD_5C:Plant_ID8553879 8.428e-05 4.590e-05 2.900e+01 1.836 0.0766 .
## GDD_5C:Plant_ID8554325 8.388e-06 4.590e-05 2.900e+01 0.183 0.8563
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C GDD_5C:P_ID85536 GDD_5C:P_ID85537
## GDD_5C -0.687
## GDD_5C:P_ID85536 0.000 -0.514
## GDD_5C:P_ID85537 0.000 -0.514 0.500
## GDD_5C:P_ID85538 0.000 -0.514 0.500 0.500
## GDD_5C:P_ID8554 0.000 -0.514 0.500 0.500
## GDD_5C:P_ID85538
## GDD_5C
## GDD_5C:P_ID85536
## GDD_5C:P_ID85537
## GDD_5C:P_ID85538
## GDD_5C:P_ID8554 0.500
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
# For Populus
lmm_model_betula_shannon16 <- lmer(I(alphaDiv^2) ~ GDD_5C + GDD_5C:Plant_ID + (1 |
Plant_ID), data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia"))
## boundary (singular) fit: see help('isSingular')
summary(lmm_model_betula_shannon16)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: I(alphaDiv^2) ~ GDD_5C + GDD_5C:Plant_ID + (1 | Plant_ID)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia")
##
## REML criterion at convergence: 229.7
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.25142 -0.60107 -0.07831 0.53159 1.85770
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0.000 0.000
## Residual 8.493 2.914
## Number of obs: 35, groups: Plant_ID, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 6.6034649 1.1512386 29.0000000 5.736 3.29e-06 ***
## GDD_5C 0.0001505 0.0009505 29.0000000 0.158 0.8753
## GDD_5C:Plant_ID8553606 0.0006789 0.0009771 29.0000000 0.695 0.4928
## GDD_5C:Plant_ID8553762 0.0004723 0.0009771 29.0000000 0.483 0.6325
## GDD_5C:Plant_ID8553879 -0.0017076 0.0009771 29.0000000 -1.748 0.0911 .
## GDD_5C:Plant_ID8554325 -0.0003603 0.0009771 29.0000000 -0.369 0.7150
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C GDD_5C:P_ID85536 GDD_5C:P_ID85537
## GDD_5C -0.687
## GDD_5C:P_ID85536 0.000 -0.514
## GDD_5C:P_ID85537 0.000 -0.514 0.500
## GDD_5C:P_ID85538 0.000 -0.514 0.500 0.500
## GDD_5C:P_ID8554 0.000 -0.514 0.500 0.500
## GDD_5C:P_ID85538
## GDD_5C
## GDD_5C:P_ID85536
## GDD_5C:P_ID85537
## GDD_5C:P_ID85538
## GDD_5C:P_ID8554 0.500
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
# For Populus
lmm_model_betula_shannon17 <- lmer(sqrt(alphaDiv) ~ GDD_5C + GDD_5C:Plant_ID + (1 |
Plant_ID), data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia"))
## boundary (singular) fit: see help('isSingular')
summary(lmm_model_betula_shannon17)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: sqrt(alphaDiv) ~ GDD_5C + GDD_5C:Plant_ID + (1 | Plant_ID)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia")
##
## REML criterion at convergence: 74.4
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.62491 -0.55306 0.05802 0.66978 1.30283
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 7.619e-20 2.760e-10
## Residual 4.015e-02 2.004e-01
## Number of obs: 35, groups: Plant_ID, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 1.576e+00 7.916e-02 2.900e+01 19.911 <2e-16 ***
## GDD_5C 1.030e-05 6.535e-05 2.900e+01 0.158 0.8759
## GDD_5C:Plant_ID8553606 4.440e-05 6.719e-05 2.900e+01 0.661 0.5139
## GDD_5C:Plant_ID8553762 5.001e-06 6.719e-05 2.900e+01 0.074 0.9412
## GDD_5C:Plant_ID8553879 -1.252e-04 6.719e-05 2.900e+01 -1.863 0.0726 .
## GDD_5C:Plant_ID8554325 -1.997e-05 6.719e-05 2.900e+01 -0.297 0.7684
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C GDD_5C:P_ID85536 GDD_5C:P_ID85537
## GDD_5C -0.687
## GDD_5C:P_ID85536 0.000 -0.514
## GDD_5C:P_ID85537 0.000 -0.514 0.500
## GDD_5C:P_ID85538 0.000 -0.514 0.500 0.500
## GDD_5C:P_ID8554 0.000 -0.514 0.500 0.500
## GDD_5C:P_ID85538
## GDD_5C
## GDD_5C:P_ID85536
## GDD_5C:P_ID85537
## GDD_5C:P_ID85538
## GDD_5C:P_ID8554 0.500
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
# For Betula
lmm_model_betula_shannon18 <- lmer(alphaDiv ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID +
(1 | Plant_ID), data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia"))
summary(lmm_model_betula_shannon18)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: alphaDiv ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID + (1 | Plant_ID)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia")
##
## REML criterion at convergence: 131.3
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.37579 -0.48022 -0.04077 0.63885 1.44018
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0.008962 0.09467
## Residual 0.377669 0.61455
## Number of obs: 35, groups: Plant_ID, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 2.967e+00 5.510e-01 1.386e-07 5.384 1.000
## GDD_5C -2.257e-04 3.405e-04 2.500e+01 -0.663 0.514
## Plant_ID8553606 -4.223e-01 7.793e-01 1.386e-07 -0.542 1.000
## Plant_ID8553762 -2.341e-01 7.793e-01 1.386e-07 -0.300 1.000
## Plant_ID8553879 -1.226e+00 7.793e-01 1.386e-07 -1.573 1.000
## Plant_ID8554325 -3.843e-01 7.793e-01 1.386e-07 -0.493 1.000
## GDD_5C:Plant_ID8553606 3.770e-04 4.816e-04 2.500e+01 0.783 0.441
## GDD_5C:Plant_ID8553762 1.788e-04 4.816e-04 2.500e+01 0.371 0.714
## GDD_5C:Plant_ID8553879 3.234e-04 4.816e-04 2.500e+01 0.671 0.508
## GDD_5C:Plant_ID8554325 1.516e-04 4.816e-04 2.500e+01 0.315 0.756
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C P_ID85536 P_ID85537 P_ID85538 P_ID8554
## GDD_5C -0.890
## P_ID8553606 -0.707 0.630
## P_ID8553762 -0.707 0.630 0.500
## P_ID8553879 -0.707 0.630 0.500 0.500
## P_ID8554325 -0.707 0.630 0.500 0.500 0.500
## GDD_5C:P_ID85536 0.630 -0.707 -0.890 -0.445 -0.445 -0.445
## GDD_5C:P_ID85537 0.630 -0.707 -0.445 -0.890 -0.445 -0.445
## GDD_5C:P_ID85538 0.630 -0.707 -0.445 -0.445 -0.890 -0.445
## GDD_5C:P_ID8554 0.630 -0.707 -0.445 -0.445 -0.445 -0.890
## GDD_5C:P_ID85536 GDD_5C:P_ID85537 GDD_5C:P_ID85538
## GDD_5C
## P_ID8553606
## P_ID8553762
## P_ID8553879
## P_ID8554325
## GDD_5C:P_ID85536
## GDD_5C:P_ID85537 0.500
## GDD_5C:P_ID85538 0.500 0.500
## GDD_5C:P_ID8554 0.500 0.500 0.500
# For Betula
lmm_model_betula_shannon19 <- lmer((1/alphaDiv) ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID +
(1 | Plant_ID), data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia"))
summary(lmm_model_betula_shannon19)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: (1/alphaDiv) ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID + (1 | Plant_ID)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia")
##
## REML criterion at convergence: 56.6
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.24849 -0.70570 -0.00214 0.39900 2.78038
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0.0003801 0.0195
## Residual 0.0190208 0.1379
## Number of obs: 35, groups: Plant_ID, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 3.260e-01 1.234e-01 1.937e-07 2.642 1.000
## GDD_5C 4.597e-05 7.642e-05 2.500e+01 0.601 0.553
## Plant_ID8553606 8.450e-02 1.745e-01 1.937e-07 0.484 1.000
## Plant_ID8553762 -7.960e-03 1.745e-01 1.937e-07 -0.046 1.000
## Plant_ID8553879 2.769e-01 1.745e-01 1.937e-07 1.587 1.000
## Plant_ID8554325 1.087e-01 1.745e-01 1.937e-07 0.623 1.000
## GDD_5C:Plant_ID8553606 -7.301e-05 1.081e-04 2.500e+01 -0.676 0.506
## GDD_5C:Plant_ID8553762 2.474e-05 1.081e-04 2.500e+01 0.229 0.821
## GDD_5C:Plant_ID8553879 -7.271e-05 1.081e-04 2.500e+01 -0.673 0.507
## GDD_5C:Plant_ID8554325 -5.326e-05 1.081e-04 2.500e+01 -0.493 0.626
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C P_ID85536 P_ID85537 P_ID85538 P_ID8554
## GDD_5C -0.892
## P_ID8553606 -0.707 0.631
## P_ID8553762 -0.707 0.631 0.500
## P_ID8553879 -0.707 0.631 0.500 0.500
## P_ID8554325 -0.707 0.631 0.500 0.500 0.500
## GDD_5C:P_ID85536 0.631 -0.707 -0.892 -0.446 -0.446 -0.446
## GDD_5C:P_ID85537 0.631 -0.707 -0.446 -0.892 -0.446 -0.446
## GDD_5C:P_ID85538 0.631 -0.707 -0.446 -0.446 -0.892 -0.446
## GDD_5C:P_ID8554 0.631 -0.707 -0.446 -0.446 -0.446 -0.892
## GDD_5C:P_ID85536 GDD_5C:P_ID85537 GDD_5C:P_ID85538
## GDD_5C
## P_ID8553606
## P_ID8553762
## P_ID8553879
## P_ID8554325
## GDD_5C:P_ID85536
## GDD_5C:P_ID85537 0.500
## GDD_5C:P_ID85538 0.500 0.500
## GDD_5C:P_ID8554 0.500 0.500 0.500
# For Betula
lmm_model_betula_shannon20 <- lmer(log(alphaDiv) ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID +
(1 | Plant_ID), data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia"))
summary(lmm_model_betula_shannon20)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: log(alphaDiv) ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID + (1 | Plant_ID)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia")
##
## REML criterion at convergence: 91.3
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.59564 -0.49588 0.01097 0.61611 1.30982
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0.0004207 0.02051
## Residual 0.0761592 0.27597
## Number of obs: 35, groups: Plant_ID, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 1.101e+00 2.446e-01 2.279e-06 4.499 1.000
## GDD_5C -1.014e-04 1.529e-04 2.500e+01 -0.663 0.513
## Plant_ID8553606 -1.900e-01 3.460e-01 2.279e-06 -0.549 1.000
## Plant_ID8553762 -4.682e-02 3.460e-01 2.279e-06 -0.135 1.000
## Plant_ID8553879 -5.710e-01 3.460e-01 2.279e-06 -1.650 1.000
## Plant_ID8554325 -2.078e-01 3.460e-01 2.279e-06 -0.601 1.000
## GDD_5C:Plant_ID8553606 1.656e-04 2.163e-04 2.500e+01 0.766 0.451
## GDD_5C:Plant_ID8553762 1.811e-05 2.163e-04 2.500e+01 0.084 0.934
## GDD_5C:Plant_ID8553879 1.524e-04 2.163e-04 2.500e+01 0.705 0.487
## GDD_5C:Plant_ID8554325 9.389e-05 2.163e-04 2.500e+01 0.434 0.668
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C P_ID85536 P_ID85537 P_ID85538 P_ID8554
## GDD_5C -0.901
## P_ID8553606 -0.707 0.637
## P_ID8553762 -0.707 0.637 0.500
## P_ID8553879 -0.707 0.637 0.500 0.500
## P_ID8554325 -0.707 0.637 0.500 0.500 0.500
## GDD_5C:P_ID85536 0.637 -0.707 -0.901 -0.450 -0.450 -0.450
## GDD_5C:P_ID85537 0.637 -0.707 -0.450 -0.901 -0.450 -0.450
## GDD_5C:P_ID85538 0.637 -0.707 -0.450 -0.450 -0.901 -0.450
## GDD_5C:P_ID8554 0.637 -0.707 -0.450 -0.450 -0.450 -0.901
## GDD_5C:P_ID85536 GDD_5C:P_ID85537 GDD_5C:P_ID85538
## GDD_5C
## P_ID8553606
## P_ID8553762
## P_ID8553879
## P_ID8554325
## GDD_5C:P_ID85536
## GDD_5C:P_ID85537 0.500
## GDD_5C:P_ID85538 0.500 0.500
## GDD_5C:P_ID8554 0.500 0.500 0.500
# For Betula
lmm_model_betula_shannon21 <- lmer(sqrt(alphaDiv) ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID +
(1 | Plant_ID), data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia"))
## Warning in as_lmerModLT(model, devfun): Model may not have converged with 1
## eigenvalue close to zero: 1.6e-10
summary(lmm_model_betula_shannon21)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: sqrt(alphaDiv) ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID + (1 | Plant_ID)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia")
##
## REML criterion at convergence: 76
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.48775 -0.50825 -0.00299 0.63049 1.34422
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0.09297 0.3049
## Residual 0.04134 0.2033
## Number of obs: 35, groups: Plant_ID, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 1.728e+00 3.539e-01 2.500e+01 4.882 5.06e-05 ***
## GDD_5C -7.556e-05 1.127e-04 2.500e+01 -0.671 0.509
## Plant_ID8553606 -1.420e-01 5.004e-01 2.500e+01 -0.284 0.779
## Plant_ID8553762 -5.684e-02 5.004e-01 2.500e+01 -0.114 0.910
## Plant_ID8553879 -4.163e-01 5.004e-01 2.500e+01 -0.832 0.413
## Plant_ID8554325 -1.421e-01 5.004e-01 2.500e+01 -0.284 0.779
## GDD_5C:Plant_ID8553606 1.249e-04 1.593e-04 2.500e+01 0.784 0.440
## GDD_5C:Plant_ID8553762 3.722e-05 1.593e-04 2.500e+01 0.234 0.817
## GDD_5C:Plant_ID8553879 1.108e-04 1.593e-04 2.500e+01 0.696 0.493
## GDD_5C:Plant_ID8554325 6.060e-05 1.593e-04 2.500e+01 0.380 0.707
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C P_ID85536 P_ID85537 P_ID85538 P_ID8554
## GDD_5C -0.459
## P_ID8553606 -0.707 0.324
## P_ID8553762 -0.707 0.324 0.500
## P_ID8553879 -0.707 0.324 0.500 0.500
## P_ID8554325 -0.707 0.324 0.500 0.500 0.500
## GDD_5C:P_ID85536 0.324 -0.707 -0.459 -0.229 -0.229 -0.229
## GDD_5C:P_ID85537 0.324 -0.707 -0.229 -0.459 -0.229 -0.229
## GDD_5C:P_ID85538 0.324 -0.707 -0.229 -0.229 -0.459 -0.229
## GDD_5C:P_ID8554 0.324 -0.707 -0.229 -0.229 -0.229 -0.459
## GDD_5C:P_ID85536 GDD_5C:P_ID85537 GDD_5C:P_ID85538
## GDD_5C
## P_ID8553606
## P_ID8553762
## P_ID8553879
## P_ID8554325
## GDD_5C:P_ID85536
## GDD_5C:P_ID85537 0.500
## GDD_5C:P_ID85538 0.500 0.500
## GDD_5C:P_ID8554 0.500 0.500 0.500
# For Betula
lmm_model_betula_shannon22 <- lmer(alphaDiv ~ GDD_5C + Plant_ID + (1 | Plant_ID),
data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia"))
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## unable to evaluate scaled gradient
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## Model failed to converge: degenerate Hessian with 1 negative eigenvalues
## Warning in as_lmerModLT(model, devfun): Model may not have converged with 1
## eigenvalue close to zero: -7.0e-10
summary(lmm_model_betula_shannon22)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: alphaDiv ~ GDD_5C + Plant_ID + (1 | Plant_ID)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia")
##
## REML criterion at convergence: 77
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.55334 -0.45007 -0.02749 0.77598 1.44368
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0.1201 0.3466
## Residual 0.3356 0.5793
## Number of obs: 35, groups: Plant_ID, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 2.670e+00 4.592e-01 2.900e+01 5.815 2.65e-06 ***
## GDD_5C -1.956e-05 1.435e-04 2.900e+01 -0.136 0.893
## Plant_ID8553606 1.209e-01 5.797e-01 2.900e+01 0.208 0.836
## Plant_ID8553762 2.356e-02 5.797e-01 2.900e+01 0.041 0.968
## Plant_ID8553879 -7.598e-01 5.797e-01 2.900e+01 -1.311 0.200
## Plant_ID8554325 -1.659e-01 5.797e-01 2.900e+01 -0.286 0.777
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C P_ID85536 P_ID85537 P_ID85538
## GDD_5C -0.450
## P_ID8553606 -0.631 0.000
## P_ID8553762 -0.631 0.000 0.500
## P_ID8553879 -0.631 0.000 0.500 0.500
## P_ID8554325 -0.631 0.000 0.500 0.500 0.500
## optimizer (nloptwrap) convergence code: 0 (OK)
## unable to evaluate scaled gradient
## Model failed to converge: degenerate Hessian with 1 negative eigenvalues
# For Betula
lmm_model_betula_shannon23 <- lmer((1/alphaDiv) ~ GDD_5C + Plant_ID + (1 | Plant_ID),
data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia"))
## Warning in as_lmerModLT(model, devfun): Model may not have converged with 1
## eigenvalue close to zero: 6.6e-11
summary(lmm_model_betula_shannon23)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: (1/alphaDiv) ~ GDD_5C + Plant_ID + (1 | Plant_ID)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia")
##
## REML criterion at convergence: -9
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.2384 -0.6491 -0.1408 0.1973 3.2326
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0.03446 0.1856
## Residual 0.01730 0.1315
## Number of obs: 35, groups: Plant_ID, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 3.762e-01 1.978e-01 2.900e+01 1.902 0.0672 .
## GDD_5C 1.112e-05 3.259e-05 2.900e+01 0.341 0.7354
## Plant_ID8553606 -2.070e-02 2.718e-01 2.900e+01 -0.076 0.9398
## Plant_ID8553762 2.769e-02 2.718e-01 2.900e+01 0.102 0.9196
## Plant_ID8553879 1.721e-01 2.718e-01 2.900e+01 0.633 0.5315
## Plant_ID8554325 3.199e-02 2.718e-01 2.900e+01 0.118 0.9071
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C P_ID85536 P_ID85537 P_ID85538
## GDD_5C -0.237
## P_ID8553606 -0.687 0.000
## P_ID8553762 -0.687 0.000 0.500
## P_ID8553879 -0.687 0.000 0.500 0.500
## P_ID8554325 -0.687 0.000 0.500 0.500 0.500
# For Betula
lmm_model_betula_shannon24 <- lmer(log(alphaDiv) ~ GDD_5C + Plant_ID + (1 | Plant_ID),
data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia"))
## Warning in as_lmerModLT(model, devfun): Model may not have converged with 1
## eigenvalue close to zero: -2.4e-13
summary(lmm_model_betula_shannon24)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: log(alphaDiv) ~ GDD_5C + Plant_ID + (1 | Plant_ID)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia")
##
## REML criterion at convergence: 30.8
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.92433 -0.31886 0.01127 0.75577 1.24071
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0.02412 0.1553
## Residual 0.06822 0.2612
## Number of obs: 35, groups: Plant_ID, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 9.767e-01 2.063e-01 2.900e+01 4.734 5.31e-05 ***
## GDD_5C -1.539e-05 6.472e-05 2.900e+01 -0.238 0.814
## Plant_ID8553606 4.853e-02 2.602e-01 2.900e+01 0.186 0.853
## Plant_ID8553762 -2.072e-02 2.602e-01 2.900e+01 -0.080 0.937
## Plant_ID8553879 -3.513e-01 2.602e-01 2.900e+01 -1.350 0.187
## Plant_ID8554325 -7.250e-02 2.602e-01 2.900e+01 -0.279 0.783
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C P_ID85536 P_ID85537 P_ID85538
## GDD_5C -0.452
## P_ID8553606 -0.631 0.000
## P_ID8553762 -0.631 0.000 0.500
## P_ID8553879 -0.631 0.000 0.500 0.500
## P_ID8554325 -0.631 0.000 0.500 0.500 0.500
# For Betula
lmm_model_betula_shannon25 <- lmer(sqrt(alphaDiv) ~ GDD_5C + Plant_ID + (1 | Plant_ID),
data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia"))
## Warning in as_lmerModLT(model, devfun): Model may not have converged with 1
## eigenvalue close to zero: 2.0e-10
summary(lmm_model_betula_shannon25)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: sqrt(alphaDiv) ~ GDD_5C + Plant_ID + (1 | Plant_ID)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia")
##
## REML criterion at convergence: 12.9
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.74278 -0.38071 -0.00533 0.75985 1.33931
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0.08285 0.2878
## Residual 0.03684 0.1919
## Number of obs: 35, groups: Plant_ID, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 1.631e+00 3.046e-01 2.900e+01 5.355 9.45e-06 ***
## GDD_5C -8.851e-06 4.756e-05 2.900e+01 -0.186 0.854
## Plant_ID8553606 3.798e-02 4.198e-01 2.900e+01 0.090 0.929
## Plant_ID8553762 -3.200e-03 4.198e-01 2.900e+01 -0.008 0.994
## Plant_ID8553879 -2.566e-01 4.198e-01 2.900e+01 -0.611 0.546
## Plant_ID8554325 -5.479e-02 4.198e-01 2.900e+01 -0.131 0.897
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C P_ID85536 P_ID85537 P_ID85538
## GDD_5C -0.225
## P_ID8553606 -0.689 0.000
## P_ID8553762 -0.689 0.000 0.500
## P_ID8553879 -0.689 0.000 0.500 0.500
## P_ID8554325 -0.689 0.000 0.500 0.500 0.500
NOTE: The only models WITHOUT Singularity issues
are: - lmm_model_betula_shannon8 -
lmm_model_betula_shannon9 -
lmm_model_betula_shannon10 -
lmm_model_betula_shannon11 -
lmm_model_betula_shannon12
#-------------------------------------------------------------------------
## To be sure of my model, let's run formal diagnostics:
#-------------------------------------------------------------------------
# Formal Test of Normality (Shapiro-Wilks)
#-------------------------------------------------------------------------
shapiro.test(residuals(lmm_model_betula_shannon1)) # p=0.5433 -> Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_betula_shannon1)
## W = 0.97297, p-value = 0.5298
shapiro.test(residuals(lmm_model_betula_shannon2)) # p=0.2564 -> Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_betula_shannon2)
## W = 0.96052, p-value = 0.237
shapiro.test(residuals(lmm_model_betula_shannon3)) # p=0.8828 -> Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_betula_shannon3)
## W = 0.98343, p-value = 0.8635
shapiro.test(residuals(lmm_model_betula_shannon4)) # p=0.09625-> Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_betula_shannon4)
## W = 0.94667, p-value = 0.08956
shapiro.test(residuals(lmm_model_betula_shannon5)) # p=0.0109 -> NOT Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_betula_shannon5)
## W = 0.9149, p-value = 0.01019
shapiro.test(residuals(lmm_model_betula_shannon6)) # p=0.9165 -> Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_betula_shannon6)
## W = 0.9871, p-value = 0.9473
shapiro.test(residuals(lmm_model_betula_shannon7)) # p=0.1556 -> Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_betula_shannon7)
## W = 0.95377, p-value = 0.1479
shapiro.test(residuals(lmm_model_betula_shannon8)) # p=0.8539 -> Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_betula_shannon8)
## W = 0.98242, p-value = 0.8346
shapiro.test(residuals(lmm_model_betula_shannon9)) # p=0.8019 -> Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_betula_shannon9)
## W = 0.98171, p-value = 0.8133
shapiro.test(residuals(lmm_model_betula_shannon10)) # p=0.3257 -> Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_betula_shannon10)
## W = 0.96488, p-value = 0.3186
shapiro.test(residuals(lmm_model_betula_shannon11)) # p=0.0001553 -> NOT Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_betula_shannon11)
## W = 0.84136, p-value = 0.0001477
shapiro.test(residuals(lmm_model_betula_shannon12)) # p=0.04153 -> Not QUIT Normal/Approx. Normal?!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_betula_shannon12)
## W = 0.93505, p-value = 0.03961
shapiro.test(residuals(lmm_model_betula_shannon13)) # p=0.5258 -> Normal
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_betula_shannon13)
## W = 0.97257, p-value = 0.5175
shapiro.test(residuals(lmm_model_betula_shannon14)) # p=0.04229 -> Not QUIT Normal/Approx. Normal?!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_betula_shannon14)
## W = 0.9351, p-value = 0.03976
shapiro.test(residuals(lmm_model_betula_shannon15)) # p=0.00228 -> NOT Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_betula_shannon15)
## W = 0.88987, p-value = 0.002136
shapiro.test(residuals(lmm_model_betula_shannon16)) # p=0.9321 -> Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_betula_shannon16)
## W = 0.9871, p-value = 0.9473
shapiro.test(residuals(lmm_model_betula_shannon17)) # p=0.1546 -> Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_betula_shannon17)
## W = 0.95377, p-value = 0.1479
shapiro.test(residuals(lmm_model_betula_shannon18))
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_betula_shannon18)
## W = 0.97297, p-value = 0.5298
shapiro.test(residuals(lmm_model_betula_shannon19)) #NOT Normal
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_betula_shannon19)
## W = 0.9149, p-value = 0.01019
shapiro.test(residuals(lmm_model_betula_shannon20))
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_betula_shannon20)
## W = 0.94667, p-value = 0.08956
shapiro.test(residuals(lmm_model_betula_shannon21))
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_betula_shannon21)
## W = 0.96052, p-value = 0.237
shapiro.test(residuals(lmm_model_betula_shannon22))
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_betula_shannon22)
## W = 0.96648, p-value = 0.3541
shapiro.test(residuals(lmm_model_betula_shannon23)) #NOT Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_betula_shannon23)
## W = 0.87904, p-value = 0.001132
shapiro.test(residuals(lmm_model_betula_shannon24)) #NOT Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_betula_shannon24)
## W = 0.93004, p-value = 0.02805
shapiro.test(residuals(lmm_model_betula_shannon25))
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_betula_shannon25)
## W = 0.95033, p-value = 0.116
#-------------------------------------------------------------------------
## Check Diagnostic Statistics/Assumptions
#-------------------------------------------------------------------------
check_model(lmm_model_betula_shannon1, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_betula_shannon2, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_betula_shannon3, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_betula_shannon4, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_betula_shannon5, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_betula_shannon6, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_betula_shannon7, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_betula_shannon8, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_betula_shannon9, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_betula_shannon10, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_betula_shannon11, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_betula_shannon12, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_betula_shannon13, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_betula_shannon14, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_betula_shannon15, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_betula_shannon16, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_betula_shannon17, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_betula_shannon18, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_betula_shannon19, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_betula_shannon20, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_betula_shannon21, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_betula_shannon22, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_betula_shannon23, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_betula_shannon24, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_betula_shannon25, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
NOTE: lmm_model_betula_shannon7,
lmm_model_betula_shannon13,
lmm_model_betula_shannon14, and
lmm_model_betula_shannon17 all seem to have the best
diagnostics above… BUT: Worried that they have a SINGULARITY issue!
SO: Next best is between lmm_model_betula_shannon8,
lmm_model_betula_shannon10, and
lmm_model_betula_shannon12 -> all relatively
similar…
IF: Singularity is not an issue, I would choose
lmm_model_betula_shannon17 !
#-------------------------------------------------------------------------
## Compare Model Fits with anova():
#-------------------------------------------------------------------------
# Compare 'model' with ANCOVA model:
anova(lmm_model_betula_shannon1, lmm_model_betula_shannon2, lmm_model_betula_shannon3,
lmm_model_betula_shannon4, lmm_model_betula_shannon5, lmm_model_betula_shannon6,
lmm_model_betula_shannon7, lmm_model_betula_shannon8, lmm_model_betula_shannon9,
lmm_model_betula_shannon10, lmm_model_betula_shannon11, lmm_model_betula_shannon12,
lmm_model_betula_shannon13, lmm_model_betula_shannon14, lmm_model_betula_shannon15,
lmm_model_betula_shannon16, lmm_model_betula_shannon17, lmm_model_betula_shannon18,
lmm_model_betula_shannon19, lmm_model_betula_shannon20, lmm_model_betula_shannon21,
lmm_model_betula_shannon22, lmm_model_betula_shannon23, lmm_model_betula_shannon24,
lmm_model_betula_shannon25)
## refitting model(s) with ML (instead of REML)
## Warning in optwrap(optimizer, devfun, x@theta, lower = x@lower, calc.derivs =
## TRUE, : convergence code 3 from bobyqa: bobyqa -- a trust region step failed to
## reduce q
## Data: subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia")
## Models:
## lmm_model_betula_shannon8: alphaDiv ~ GDD_5C + (1 | Plant_ID)
## lmm_model_betula_shannon9: I(alphaDiv^2) ~ GDD_5C + (1 | Plant_ID)
## lmm_model_betula_shannon10: sqrt(alphaDiv) ~ GDD_5C + (1 | Plant_ID)
## lmm_model_betula_shannon11: (1/alphaDiv) ~ GDD_5C + (1 | Plant_ID)
## lmm_model_betula_shannon12: log(alphaDiv) ~ GDD_5C + (1 | Plant_ID)
## lmm_model_betula_shannon6: I(alphaDiv^2) ~ GDD_5C + GDD_5C:Plant_ID + (1 | `Collection-Month`)
## lmm_model_betula_shannon7: sqrt(alphaDiv) ~ GDD_5C + GDD_5C:Plant_ID + (1 | `Collection-Month`)
## lmm_model_betula_shannon13: alphaDiv ~ GDD_5C + GDD_5C:Plant_ID + (1 | Plant_ID)
## lmm_model_betula_shannon14: log(alphaDiv) ~ GDD_5C + GDD_5C:Plant_ID + (1 | Plant_ID)
## lmm_model_betula_shannon15: (1/alphaDiv) ~ GDD_5C + GDD_5C:Plant_ID + (1 | Plant_ID)
## lmm_model_betula_shannon16: I(alphaDiv^2) ~ GDD_5C + GDD_5C:Plant_ID + (1 | Plant_ID)
## lmm_model_betula_shannon17: sqrt(alphaDiv) ~ GDD_5C + GDD_5C:Plant_ID + (1 | Plant_ID)
## lmm_model_betula_shannon22: alphaDiv ~ GDD_5C + Plant_ID + (1 | Plant_ID)
## lmm_model_betula_shannon23: (1/alphaDiv) ~ GDD_5C + Plant_ID + (1 | Plant_ID)
## lmm_model_betula_shannon24: log(alphaDiv) ~ GDD_5C + Plant_ID + (1 | Plant_ID)
## lmm_model_betula_shannon25: sqrt(alphaDiv) ~ GDD_5C + Plant_ID + (1 | Plant_ID)
## lmm_model_betula_shannon1: alphaDiv ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID + (1 | `Collection-Month`)
## lmm_model_betula_shannon2: sqrt(alphaDiv) ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID + (1 | `Collection-Month`)
## lmm_model_betula_shannon3: I(alphaDiv^2) ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID + (1 | `Collection-Month`)
## lmm_model_betula_shannon4: log(alphaDiv) ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID + (1 | `Collection-Month`)
## lmm_model_betula_shannon5: (1/alphaDiv) ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID + (1 | `Collection-Month`)
## lmm_model_betula_shannon18: alphaDiv ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID + (1 | Plant_ID)
## lmm_model_betula_shannon19: (1/alphaDiv) ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID + (1 | Plant_ID)
## lmm_model_betula_shannon20: log(alphaDiv) ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID + (1 | Plant_ID)
## lmm_model_betula_shannon21: sqrt(alphaDiv) ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID + (1 | Plant_ID)
## npar AIC BIC logLik deviance Chisq Df
## lmm_model_betula_shannon8 4 71.748 77.969 -31.874 63.748
## lmm_model_betula_shannon9 4 182.417 188.638 -87.208 174.417 0.000 0
## lmm_model_betula_shannon10 4 -5.552 0.669 6.776 -13.552 187.969 0
## lmm_model_betula_shannon11 4 -32.605 -26.384 20.303 -40.605 27.053 0
## lmm_model_betula_shannon12 4 15.932 22.153 -3.966 7.932 0.000 0
## lmm_model_betula_shannon6 8 183.616 196.059 -83.808 167.616 0.000 4
## lmm_model_betula_shannon7 8 -3.785 8.658 9.893 -19.785 187.401 0
## lmm_model_betula_shannon13 8 73.315 85.758 -28.658 57.315 0.000 0
## lmm_model_betula_shannon14 8 17.872 30.315 -0.936 1.872 55.443 0
## lmm_model_betula_shannon15 8 -30.458 -18.015 23.229 -46.458 48.330 0
## lmm_model_betula_shannon16 8 183.616 196.059 -83.808 167.616 0.000 0
## lmm_model_betula_shannon17 8 -3.785 8.658 9.893 -19.785 187.401 0
## lmm_model_betula_shannon22 8 70.528 82.971 -27.264 54.528 0.000 0
## lmm_model_betula_shannon23 8 -33.263 -20.820 24.631 -49.263 103.791 0
## lmm_model_betula_shannon24 8 14.767 27.209 0.617 -1.233 0.000 0
## lmm_model_betula_shannon25 8 -6.802 5.641 11.401 -22.802 21.568 0
## lmm_model_betula_shannon1 12 77.468 96.133 -26.734 53.468 0.000 4
## lmm_model_betula_shannon2 12 0.039 18.703 11.981 -23.961 77.430 0
## lmm_model_betula_shannon3 12 188.456 207.121 -82.228 164.456 0.000 0
## lmm_model_betula_shannon4 12 21.427 40.091 1.287 -2.573 167.030 0
## lmm_model_betula_shannon5 12 -27.129 -8.464 25.564 -51.129 48.555 0
## lmm_model_betula_shannon18 12 77.468 96.133 -26.734 53.468 0.000 0
## lmm_model_betula_shannon19 12 -27.129 -8.464 25.564 -51.129 104.597 0
## lmm_model_betula_shannon20 12 21.427 40.091 1.287 -2.573 0.000 0
## lmm_model_betula_shannon21 12 0.039 18.703 11.981 -23.961 21.388 0
## Pr(>Chisq)
## lmm_model_betula_shannon8
## lmm_model_betula_shannon9
## lmm_model_betula_shannon10
## lmm_model_betula_shannon11
## lmm_model_betula_shannon12
## lmm_model_betula_shannon6 1
## lmm_model_betula_shannon7
## lmm_model_betula_shannon13
## lmm_model_betula_shannon14
## lmm_model_betula_shannon15
## lmm_model_betula_shannon16
## lmm_model_betula_shannon17
## lmm_model_betula_shannon22
## lmm_model_betula_shannon23
## lmm_model_betula_shannon24
## lmm_model_betula_shannon25
## lmm_model_betula_shannon1 1
## lmm_model_betula_shannon2
## lmm_model_betula_shannon3
## lmm_model_betula_shannon4
## lmm_model_betula_shannon5
## lmm_model_betula_shannon18
## lmm_model_betula_shannon19
## lmm_model_betula_shannon20
## lmm_model_betula_shannon21
## Best is `lmm_model_betula_shannon11`, BUT: Posterior Predictive Check &
## Influential Observations/Outliers is worse than
## `lmm_model_betula_shannon10`, but has better Homogeneity of Variance and
## Linearity.
## Next Best: `lmm_model_betula_shannon15` -> BUT: worried about Singularity
## issue AND terrible diagnostic stats with check_model()
## Next Best: `lmm_model_betula_shannon5` has best stats here, BUT: Has
## collinearity AND singularity issues
## NEXT BEST/LIKELY CHOICE: `lmm_model_betula_shannon10` or
## `lmm_model_betula_shannon11`
## NOTE: Even though `lmm_model_betula_shannon11` isn't normally distributed,
## keep in mind that this is often the case with biological data.
############################################################### IF SINGULARITY
############################################################### ALLOWED:
############################################################### `lmm_model_betula_shannon17`
# ANOVA of LMM model using `car` package.
library(car)
anova_lmm_betula_shannon1 <- Anova(lmm_model_betula_shannon1)
anova_lmm_betula_shannon2 <- Anova(lmm_model_betula_shannon2)
anova_lmm_betula_shannon3 <- Anova(lmm_model_betula_shannon3)
anova_lmm_betula_shannon4 <- Anova(lmm_model_betula_shannon4)
anova_lmm_betula_shannon5 <- Anova(lmm_model_betula_shannon5)
anova_lmm_betula_shannon6 <- Anova(lmm_model_betula_shannon6)
anova_lmm_betula_shannon7 <- Anova(lmm_model_betula_shannon7)
anova_lmm_betula_shannon8 <- Anova(lmm_model_betula_shannon8)
anova_lmm_betula_shannon9 <- Anova(lmm_model_betula_shannon9)
anova_lmm_betula_shannon10 <- Anova(lmm_model_betula_shannon10)
anova_lmm_betula_shannon11 <- Anova(lmm_model_betula_shannon11)
anova_lmm_betula_shannon12 <- Anova(lmm_model_betula_shannon12)
anova_lmm_betula_shannon13 <- Anova(lmm_model_betula_shannon13)
anova_lmm_betula_shannon14 <- Anova(lmm_model_betula_shannon14)
anova_lmm_betula_shannon15 <- Anova(lmm_model_betula_shannon15)
anova_lmm_betula_shannon16 <- Anova(lmm_model_betula_shannon16)
anova_lmm_betula_shannon17 <- Anova(lmm_model_betula_shannon17)
summary(anova_lmm_betula_shannon1)
## Chisq Df Pr(>Chisq)
## Min. :0.0165 Min. :1.0 Min. :0.05564
## 1st Qu.:0.3926 1st Qu.:2.5 1st Qu.:0.47671
## Median :0.7687 Median :4.0 Median :0.89778
## Mean :3.3379 Mean :3.0 Mean :0.63200
## 3rd Qu.:4.9986 3rd Qu.:4.0 3rd Qu.:0.92019
## Max. :9.2284 Max. :4.0 Max. :0.94259
summary(anova_lmm_betula_shannon2)
## Chisq Df Pr(>Chisq)
## Min. :0.03086 Min. :1.0 Min. :0.05379
## 1st Qu.:0.43652 1st Qu.:2.5 1st Qu.:0.45717
## Median :0.84218 Median :4.0 Median :0.86055
## Mean :3.39453 Mean :3.0 Mean :0.61568
## 3rd Qu.:5.07637 3rd Qu.:4.0 3rd Qu.:0.89663
## Max. :9.31056 Max. :4.0 Max. :0.93271
summary(anova_lmm_betula_shannon3)
## Chisq Df Pr(>Chisq)
## Min. :0.001955 Min. :1.0 Min. :0.07172
## 1st Qu.:0.398065 1st Qu.:2.5 1st Qu.:0.50547
## Median :0.794175 Median :4.0 Median :0.93923
## Mean :3.134233 Mean :3.0 Mean :0.65856
## 3rd Qu.:4.700373 3rd Qu.:4.0 3rd Qu.:0.95198
## Max. :8.606571 Max. :4.0 Max. :0.96474
summary(anova_lmm_betula_shannon4)
## Chisq Df Pr(>Chisq)
## Min. :0.05066 Min. :1.0 Min. :0.05626
## 1st Qu.:0.51316 1st Qu.:2.5 1st Qu.:0.43909
## Median :0.97567 Median :4.0 Median :0.82192
## Mean :3.40924 Mean :3.0 Mean :0.59721
## 3rd Qu.:5.08853 3rd Qu.:4.0 3rd Qu.:0.86769
## Max. :9.20138 Max. :4.0 Max. :0.91346
summary(anova_lmm_betula_shannon5)
## Chisq Df Pr(>Chisq)
## Min. :0.1058 Min. :1.0 Min. :0.07675
## 1st Qu.:0.7373 1st Qu.:2.5 1st Qu.:0.41084
## Median :1.3688 Median :4.0 Median :0.74493
## Mean :3.3046 Mean :3.0 Mean :0.55709
## 3rd Qu.:4.9040 3rd Qu.:4.0 3rd Qu.:0.79727
## Max. :8.4393 Max. :4.0 Max. :0.84960
summary(anova_lmm_betula_shannon6)
## Chisq Df Pr(>Chisq)
## Min. :0.002072 Min. :1.00 Min. :0.1135
## 1st Qu.:1.866594 1st Qu.:1.75 1st Qu.:0.3260
## Median :3.731116 Median :2.50 Median :0.5386
## Mean :3.731116 Mean :2.50 Mean :0.5386
## 3rd Qu.:5.595639 3rd Qu.:3.25 3rd Qu.:0.7511
## Max. :7.460161 Max. :4.00 Max. :0.9637
summary(anova_lmm_betula_shannon7)
## Chisq Df Pr(>Chisq)
## Min. :0.03177 Min. :1.00 Min. :0.1262
## 1st Qu.:1.82148 1st Qu.:1.75 1st Qu.:0.3092
## Median :3.61119 Median :2.50 Median :0.4923
## Mean :3.61119 Mean :2.50 Mean :0.4923
## 3rd Qu.:5.40090 3rd Qu.:3.25 3rd Qu.:0.6754
## Max. :7.19061 Max. :4.00 Max. :0.8585
summary(anova_lmm_betula_shannon8)
## Chisq Df Pr(>Chisq)
## Min. :0.01857 Min. :1 Min. :0.8916
## 1st Qu.:0.01857 1st Qu.:1 1st Qu.:0.8916
## Median :0.01857 Median :1 Median :0.8916
## Mean :0.01857 Mean :1 Mean :0.8916
## 3rd Qu.:0.01857 3rd Qu.:1 3rd Qu.:0.8916
## Max. :0.01857 Max. :1 Max. :0.8916
summary(anova_lmm_betula_shannon9)
## Chisq Df Pr(>Chisq)
## Min. :0.002197 Min. :1 Min. :0.9626
## 1st Qu.:0.002197 1st Qu.:1 1st Qu.:0.9626
## Median :0.002197 Median :1 Median :0.9626
## Mean :0.002197 Mean :1 Mean :0.9626
## 3rd Qu.:0.002197 3rd Qu.:1 3rd Qu.:0.9626
## Max. :0.002197 Max. :1 Max. :0.9626
summary(anova_lmm_betula_shannon10)
## Chisq Df Pr(>Chisq)
## Min. :0.03463 Min. :1 Min. :0.8524
## 1st Qu.:0.03463 1st Qu.:1 1st Qu.:0.8524
## Median :0.03463 Median :1 Median :0.8524
## Mean :0.03463 Mean :1 Mean :0.8524
## 3rd Qu.:0.03463 3rd Qu.:1 3rd Qu.:0.8524
## Max. :0.03463 Max. :1 Max. :0.8524
summary(anova_lmm_betula_shannon11)
## Chisq Df Pr(>Chisq)
## Min. :0.1164 Min. :1 Min. :0.733
## 1st Qu.:0.1164 1st Qu.:1 1st Qu.:0.733
## Median :0.1164 Median :1 Median :0.733
## Mean :0.1164 Mean :1 Mean :0.733
## 3rd Qu.:0.1164 3rd Qu.:1 3rd Qu.:0.733
## Max. :0.1164 Max. :1 Max. :0.733
summary(anova_lmm_betula_shannon12)
## Chisq Df Pr(>Chisq)
## Min. :0.05656 Min. :1 Min. :0.812
## 1st Qu.:0.05656 1st Qu.:1 1st Qu.:0.812
## Median :0.05656 Median :1 Median :0.812
## Mean :0.05656 Mean :1 Mean :0.812
## 3rd Qu.:0.05656 3rd Qu.:1 3rd Qu.:0.812
## Max. :0.05656 Max. :1 Max. :0.812
summary(anova_lmm_betula_shannon13)
## Chisq Df Pr(>Chisq)
## Min. :0.01715 Min. :1.00 Min. :0.1175
## 1st Qu.:1.85569 1st Qu.:1.75 1st Qu.:0.3121
## Median :3.69423 Median :2.50 Median :0.5067
## Mean :3.69423 Mean :2.50 Mean :0.5067
## 3rd Qu.:5.53277 3rd Qu.:3.25 3rd Qu.:0.7012
## Max. :7.37130 Max. :4.00 Max. :0.8958
summary(anova_lmm_betula_shannon14)
## Chisq Df Pr(>Chisq)
## Min. :0.05176 Min. :1.00 Min. :0.1392
## 1st Qu.:1.77333 1st Qu.:1.75 1st Qu.:0.3094
## Median :3.49491 Median :2.50 Median :0.4796
## Mean :3.49491 Mean :2.50 Mean :0.4796
## 3rd Qu.:5.21648 3rd Qu.:3.25 3rd Qu.:0.6498
## Max. :6.93806 Max. :4.00 Max. :0.8200
summary(anova_lmm_betula_shannon15)
## Chisq Df Pr(>Chisq)
## Min. :0.1074 Min. :1.00 Min. :0.1756
## 1st Qu.:1.6638 1st Qu.:1.75 1st Qu.:0.3175
## Median :3.2202 Median :2.50 Median :0.4594
## Mean :3.2202 Mean :2.50 Mean :0.4594
## 3rd Qu.:4.7765 3rd Qu.:3.25 3rd Qu.:0.6012
## Max. :6.3329 Max. :4.00 Max. :0.7431
summary(anova_lmm_betula_shannon16)
## Chisq Df Pr(>Chisq)
## Min. :0.002072 Min. :1.00 Min. :0.1135
## 1st Qu.:1.866594 1st Qu.:1.75 1st Qu.:0.3260
## Median :3.731116 Median :2.50 Median :0.5386
## Mean :3.731116 Mean :2.50 Mean :0.5386
## 3rd Qu.:5.595639 3rd Qu.:3.25 3rd Qu.:0.7511
## Max. :7.460161 Max. :4.00 Max. :0.9637
summary(anova_lmm_betula_shannon17)
## Chisq Df Pr(>Chisq)
## Min. :0.03177 Min. :1.00 Min. :0.1262
## 1st Qu.:1.82148 1st Qu.:1.75 1st Qu.:0.3092
## Median :3.61119 Median :2.50 Median :0.4923
## Mean :3.61119 Mean :2.50 Mean :0.4923
## 3rd Qu.:5.40090 3rd Qu.:3.25 3rd Qu.:0.6754
## Max. :7.19061 Max. :4.00 Max. :0.8585
# Supports `anova_lmm_betula_shannon17` (but has singularity issue) and
# `anova_lmm_betula_shannon7` (but has BOTH singularity AND collinearity
# issues)
################################################################################ CHOICE:
################################################################################ `lmm_model_betula_shannon10`
################################################################################ (sqrt
################################################################################ transformed;
################################################################################ GDD
################################################################################ as
################################################################################ fixed;
################################################################################ Plant_ID
################################################################################ as
################################################################################ random)
lmm_model_betula_shannon10 <- lmer(sqrt(alphaDiv) ~ GDD_5C + (1 | Plant_ID), data = subset(asv_scaled_noPlants_Phen_filt_LMM,
Species == "Betula_populifolia"))
summary(lmm_model_betula_shannon10)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: sqrt(alphaDiv) ~ GDD_5C + (1 | Plant_ID)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia")
##
## REML criterion at convergence: 8.7
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.6388 -0.5592 0.1050 0.6907 1.4433
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0.008483 0.0921
## Residual 0.036835 0.1919
## Number of obs: 35, groups: Plant_ID, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 1.576e+00 8.628e-02 2.092e+01 18.266 2.47e-14 ***
## GDD_5C -8.851e-06 4.756e-05 2.900e+01 -0.186 0.854
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## GDD_5C -0.794
library(rsq)
rsq.lmm(lmm_model_betula_shannon10)
## $model
## [1] 0.1739808
##
## $fixed
## [1] 0.0008770921
##
## $random
## [1] 0.1731037
############################# OR?:
lmm_model_betula_shannon11 <- lmer((1/alphaDiv) ~ GDD_5C + (1 | Plant_ID), data = subset(asv_scaled_noPlants_Phen_filt_LMM,
Species == "Betula_populifolia"))
summary(lmm_model_betula_shannon11)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: (1/alphaDiv) ~ GDD_5C + (1 | Plant_ID)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia")
##
## REML criterion at convergence: -16.7
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.1072 -0.6960 -0.1884 0.3618 3.1850
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0.003262 0.05712
## Residual 0.017295 0.13151
## Number of obs: 35, groups: Plant_ID, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 4.184e-01 5.789e-02 2.263e+01 7.228 2.58e-07 ***
## GDD_5C 1.112e-05 3.259e-05 2.900e+01 0.341 0.735
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## GDD_5C -0.811
### THIS WILL BE OUR CHOICE^
rsq.lmm(lmm_model_betula_shannon11)
## $model
## [1] 0.1496945
##
## $fixed
## [1] 0.003031424
##
## $random
## [1] 0.146663
################################################################################ IF
################################################################################ SINGULARITY
################################################################################ ALLOWED,
################################################################################ MAYBEEEE
################################################################################ CHOOSE:
################################################################################ `lmm_model_betula_shannon17`....
# lmm_model_betula_shannon17 <- lmer(sqrt(alphaDiv) ~ GDD_5C + GDD_5C:Plant_ID
# + (1 | Plant_ID), data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species ==
# 'Betula_populifolia'))
# summary(lmm_model_betula_shannon17)
## NOTE: This is why we ikely DON'T choose the one with SINGULARITY... Notice
## that here, the R^2 for the Random Effect is 0, so NO VARIANCE in our Random
## Effect (corroborated by our ChiSq values and >Pr(ChiSq) being oddly all
## similar, and our R2c and R2m being the same too...):
# library(rsq)
# rsq.lmm(lmm_model_betula_shannon17)
# $model [1] 0.1981237
# $fixed [1] 0.1981237
# $random _> NOTE NO VARIANCE! [1] 0
#--------------------------------------------------------------
## Conditional & Marginal R^2 for `GDD_5C` in Betula
#--------------------------------------------------------------
# Calculate marginal R-squared for `GDD_5C`
betula_shannon_r_squared <- r.squaredGLMM(lmm_model_betula_shannon10, mu0 = "fixed")
print(betula_shannon_r_squared)
## R2m R2c
## [1,] 0.0008271924 0.1878594
## OR?:
betula_shannon_r_squared <- r.squaredGLMM(lmm_model_betula_shannon11, mu0 = "fixed")
print(betula_shannon_r_squared)
## R2m R2c
## [1,] 0.002871981 0.1611049
rsq.lmm(lmm_model_betula_shannon10)
## $model
## [1] 0.1739808
##
## $fixed
## [1] 0.0008770921
##
## $random
## [1] 0.1731037
rsq.lmm(lmm_model_betula_shannon11)
## $model
## [1] 0.1496945
##
## $fixed
## [1] 0.003031424
##
## $random
## [1] 0.146663
## Better R^2 values for `lmm_model_betula_shannon11`
# *NOTE: Will have to do marginal/conditional R^2 for GDD_5C:Plant_ID too!!!
# *NOTE: Odd to have both marginal & conditional R^2 be same... ?
# install.packages('urca')
library(urca)
# Perform KPSS test
kpss_betula_alphaDiv <- ur.kpss(betula_data$alphaDiv)
kpss_betula_alphaDiv <- ur.kpss(asv_scaled_noPlants_Phen_filt_LMM$alphaDiv[asv_scaled_noPlants_Phen_filt_LMM$Species ==
"Betula_populifolia"])
# summary of KPSS Test
summary(kpss_betula_alphaDiv)
##
## #######################
## # KPSS Unit Root Test #
## #######################
##
## Test is of type: mu with 3 lags.
##
## Value of test-statistic is: 0.0687
##
## Critical value for a significance level of:
## 10pct 5pct 2.5pct 1pct
## critical values 0.347 0.463 0.574 0.739
# OUTPUT: Shannon diversity in Betula is STATIONARY!
# For Populus
lmm_model_populus_shannon1 <- lmer(alphaDiv ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID +
(1 | `Collection-Month`), data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species ==
"Populus_tremuloides"))
summary(lmm_model_populus_shannon1)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## alphaDiv ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID + (1 | `Collection-Month`)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides")
##
## REML criterion at convergence: 140.1
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.1033 -0.2856 0.1286 0.6010 1.2317
##
## Random effects:
## Groups Name Variance Std.Dev.
## Collection-Month (Intercept) 0.04217 0.2053
## Residual 0.46438 0.6815
## Number of obs: 36, groups: Collection-Month, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 3.499e+00 6.192e-01 1.323e+01 5.650 7.42e-05 ***
## GDD_5C 1.098e-04 3.994e-04 1.488e+01 0.275 0.787
## Plant_ID8987955 -5.449e-03 8.313e-01 2.258e+01 -0.007 0.995
## Plant_ID8988752 1.896e-01 8.313e-01 2.258e+01 0.228 0.822
## Plant_ID8988899 -2.443e-01 8.313e-01 2.258e+01 -0.294 0.772
## Plant_ID9340742 -5.113e-01 8.313e-01 2.258e+01 -0.615 0.545
## GDD_5C:Plant_ID8987955 -1.810e-04 5.298e-04 2.244e+01 -0.342 0.736
## GDD_5C:Plant_ID8988752 -6.612e-04 5.298e-04 2.244e+01 -1.248 0.225
## GDD_5C:Plant_ID8988899 3.682e-05 5.298e-04 2.244e+01 0.069 0.945
## GDD_5C:Plant_ID9340742 1.922e-04 5.298e-04 2.244e+01 0.363 0.720
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C P_ID8987 P_ID89887 P_ID89888 P_ID93
## GDD_5C -0.908
## P_ID8987955 -0.635 0.580
## P_ID8988752 -0.635 0.580 0.476
## P_ID8988899 -0.635 0.580 0.476 0.476
## P_ID9340742 -0.635 0.580 0.476 0.476 0.476
## GDD_5C:P_ID8987 0.587 -0.652 -0.905 -0.439 -0.439 -0.439
## GDD_5C:P_ID89887 0.587 -0.652 -0.439 -0.905 -0.439 -0.439
## GDD_5C:P_ID89888 0.587 -0.652 -0.439 -0.439 -0.905 -0.439
## GDD_5C:P_ID9 0.587 -0.652 -0.439 -0.439 -0.439 -0.905
## GDD_5C:P_ID8987 GDD_5C:P_ID89887 GDD_5C:P_ID89888
## GDD_5C
## P_ID8987955
## P_ID8988752
## P_ID8988899
## P_ID9340742
## GDD_5C:P_ID8987
## GDD_5C:P_ID89887 0.492
## GDD_5C:P_ID89888 0.492 0.492
## GDD_5C:P_ID9 0.492 0.492 0.492
# For Populus
lmm_model_populus_shannon2 <- lmer(sqrt(alphaDiv) ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID +
(1 | `Collection-Month`), data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species ==
"Populus_tremuloides"))
summary(lmm_model_populus_shannon2)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## sqrt(alphaDiv) ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID + (1 | `Collection-Month`)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides")
##
## REML criterion at convergence: 84.1
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.5832 -0.2118 0.0873 0.4429 1.1726
##
## Random effects:
## Groups Name Variance Std.Dev.
## Collection-Month (Intercept) 0.007651 0.08747
## Residual 0.052584 0.22931
## Number of obs: 36, groups: Collection-Month, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 1.856e+00 2.172e-01 1.155e+01 8.544 2.49e-06 ***
## GDD_5C 3.399e-05 1.397e-04 1.310e+01 0.243 0.811
## Plant_ID8987955 5.327e-03 2.798e-01 2.264e+01 0.019 0.985
## Plant_ID8988752 3.325e-02 2.798e-01 2.264e+01 0.119 0.906
## Plant_ID8988899 -5.599e-02 2.798e-01 2.264e+01 -0.200 0.843
## Plant_ID9340742 -1.417e-01 2.798e-01 2.264e+01 -0.506 0.618
## GDD_5C:Plant_ID8987955 -5.310e-05 1.783e-04 2.253e+01 -0.298 0.769
## GDD_5C:Plant_ID8988752 -2.016e-04 1.783e-04 2.253e+01 -1.131 0.270
## GDD_5C:Plant_ID8988899 4.329e-06 1.783e-04 2.253e+01 0.024 0.981
## GDD_5C:Plant_ID9340742 5.222e-05 1.783e-04 2.253e+01 0.293 0.772
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C P_ID8987 P_ID89887 P_ID89888 P_ID93
## GDD_5C -0.909
## P_ID8987955 -0.609 0.558
## P_ID8988752 -0.609 0.558 0.476
## P_ID8988899 -0.609 0.558 0.476 0.476
## P_ID9340742 -0.609 0.558 0.476 0.476 0.476
## GDD_5C:P_ID8987 0.563 -0.627 -0.905 -0.439 -0.439 -0.439
## GDD_5C:P_ID89887 0.563 -0.627 -0.439 -0.905 -0.439 -0.439
## GDD_5C:P_ID89888 0.563 -0.627 -0.439 -0.439 -0.905 -0.439
## GDD_5C:P_ID9 0.563 -0.627 -0.439 -0.439 -0.439 -0.905
## GDD_5C:P_ID8987 GDD_5C:P_ID89887 GDD_5C:P_ID89888
## GDD_5C
## P_ID8987955
## P_ID8988752
## P_ID8988899
## P_ID9340742
## GDD_5C:P_ID8987
## GDD_5C:P_ID89887 0.492
## GDD_5C:P_ID89888 0.492 0.492
## GDD_5C:P_ID9 0.492 0.492 0.492
# For Populus
lmm_model_populus_shannon3 <- lmer(log(alphaDiv) ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID +
(1 | `Collection-Month`), data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species ==
"Populus_tremuloides"))
summary(lmm_model_populus_shannon3)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## log(alphaDiv) ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID + (1 | `Collection-Month`)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides")
##
## REML criterion at convergence: 106.3
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -4.0018 -0.1330 0.0737 0.2977 1.0854
##
## Random effects:
## Groups Name Variance Std.Dev.
## Collection-Month (Intercept) 0.02165 0.1471
## Residual 0.12227 0.3497
## Number of obs: 36, groups: Collection-Month, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 1.221e+00 3.388e-01 1.081e+01 3.603 0.00426 **
## GDD_5C 4.091e-05 2.174e-04 1.229e+01 0.188 0.85381
## Plant_ID8987955 1.320e-02 4.268e-01 2.267e+01 0.031 0.97560
## Plant_ID8988752 -4.519e-03 4.268e-01 2.267e+01 -0.011 0.99164
## Plant_ID8988899 -4.971e-02 4.268e-01 2.267e+01 -0.116 0.90830
## Plant_ID9340742 -1.593e-01 4.268e-01 2.267e+01 -0.373 0.71247
## GDD_5C:Plant_ID8987955 -6.214e-05 2.719e-04 2.257e+01 -0.229 0.82130
## GDD_5C:Plant_ID8988752 -2.590e-04 2.719e-04 2.257e+01 -0.952 0.35097
## GDD_5C:Plant_ID8988899 -1.396e-06 2.719e-04 2.257e+01 -0.005 0.99595
## GDD_5C:Plant_ID9340742 5.759e-05 2.719e-04 2.257e+01 0.212 0.83416
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C P_ID8987 P_ID89887 P_ID89888 P_ID93
## GDD_5C -0.909
## P_ID8987955 -0.596 0.546
## P_ID8988752 -0.596 0.546 0.476
## P_ID8988899 -0.596 0.546 0.476 0.476
## P_ID9340742 -0.596 0.546 0.476 0.476 0.476
## GDD_5C:P_ID8987 0.551 -0.614 -0.905 -0.439 -0.439 -0.439
## GDD_5C:P_ID89887 0.551 -0.614 -0.439 -0.905 -0.439 -0.439
## GDD_5C:P_ID89888 0.551 -0.614 -0.439 -0.439 -0.905 -0.439
## GDD_5C:P_ID9 0.551 -0.614 -0.439 -0.439 -0.439 -0.905
## GDD_5C:P_ID8987 GDD_5C:P_ID89887 GDD_5C:P_ID89888
## GDD_5C
## P_ID8987955
## P_ID8988752
## P_ID8988899
## P_ID9340742
## GDD_5C:P_ID8987
## GDD_5C:P_ID89887 0.492
## GDD_5C:P_ID89888 0.492 0.492
## GDD_5C:P_ID9 0.492 0.492 0.492
# For Populus
lmm_model_populus_shannon4 <- lmer(I(alphaDiv^2) ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID +
(1 | `Collection-Month`), data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species ==
"Populus_tremuloides"))
## boundary (singular) fit: see help('isSingular')
summary(lmm_model_populus_shannon4)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## I(alphaDiv^2) ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID + (1 | `Collection-Month`)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides")
##
## REML criterion at convergence: 228.4
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.3220 -0.4637 0.0159 0.6700 1.6227
##
## Random effects:
## Groups Name Variance Std.Dev.
## Collection-Month (Intercept) 1.038e-14 1.019e-07
## Residual 1.462e+01 3.823e+00
## Number of obs: 36, groups: Collection-Month, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 12.8729817 3.2086839 26.0000000 4.012 0.000453 ***
## GDD_5C 0.0005662 0.0020837 26.0000000 0.272 0.787964
## Plant_ID8987955 -0.4094201 4.6583722 26.0000000 -0.088 0.930638
## Plant_ID8988752 1.5538115 4.6583722 26.0000000 0.334 0.741392
## Plant_ID8988899 -2.2192210 4.6583722 26.0000000 -0.476 0.637773
## Plant_ID9340742 -3.4867993 4.6583722 26.0000000 -0.749 0.460876
## GDD_5C:Plant_ID8987955 -0.0010273 0.0029714 26.0000000 -0.346 0.732335
## GDD_5C:Plant_ID8988752 -0.0038674 0.0029714 26.0000000 -1.302 0.204486
## GDD_5C:Plant_ID8988899 0.0005503 0.0029714 26.0000000 0.185 0.854504
## GDD_5C:Plant_ID9340742 0.0013603 0.0029714 26.0000000 0.458 0.650899
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C P_ID8987 P_ID89887 P_ID89888 P_ID93
## GDD_5C -0.907
## P_ID8987955 -0.689 0.625
## P_ID8988752 -0.689 0.625 0.474
## P_ID8988899 -0.689 0.625 0.474 0.474
## P_ID9340742 -0.689 0.625 0.474 0.474 0.474
## GDD_5C:P_ID8987 0.636 -0.701 -0.905 -0.438 -0.438 -0.438
## GDD_5C:P_ID89887 0.636 -0.701 -0.438 -0.905 -0.438 -0.438
## GDD_5C:P_ID89888 0.636 -0.701 -0.438 -0.438 -0.905 -0.438
## GDD_5C:P_ID9 0.636 -0.701 -0.438 -0.438 -0.438 -0.905
## GDD_5C:P_ID8987 GDD_5C:P_ID89887 GDD_5C:P_ID89888
## GDD_5C
## P_ID8987955
## P_ID8988752
## P_ID8988899
## P_ID9340742
## GDD_5C:P_ID8987
## GDD_5C:P_ID89887 0.492
## GDD_5C:P_ID89888 0.492 0.492
## GDD_5C:P_ID9 0.492 0.492 0.492
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
# For Populus
lmm_model_populus_shannon5 <- lmer((1/alphaDiv) ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID +
(1 | `Collection-Month`), data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species ==
"Populus_tremuloides"))
summary(lmm_model_populus_shannon5)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## (1/alphaDiv) ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID + (1 | `Collection-Month`)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides")
##
## REML criterion at convergence: 97.1
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.0188 -0.2681 0.0053 0.1021 4.4044
##
## Random effects:
## Groups Name Variance Std.Dev.
## Collection-Month (Intercept) 0.01432 0.1197
## Residual 0.08623 0.2936
## Number of obs: 36, groups: Collection-Month, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 3.078e-01 2.823e-01 1.102e+01 1.090 0.299
## GDD_5C -1.386e-05 1.813e-04 1.253e+01 -0.076 0.940
## Plant_ID8987955 -9.205e-03 3.584e-01 2.265e+01 -0.026 0.980
## Plant_ID8988752 7.592e-02 3.584e-01 2.265e+01 0.212 0.834
## Plant_ID8988899 7.301e-03 3.584e-01 2.265e+01 0.020 0.984
## Plant_ID9340742 5.173e-02 3.584e-01 2.265e+01 0.144 0.887
## GDD_5C:Plant_ID8987955 2.144e-05 2.284e-04 2.254e+01 0.094 0.926
## GDD_5C:Plant_ID8988752 1.386e-04 2.284e-04 2.254e+01 0.607 0.550
## GDD_5C:Plant_ID8988899 4.307e-06 2.284e-04 2.254e+01 0.019 0.985
## GDD_5C:Plant_ID9340742 -1.808e-05 2.284e-04 2.254e+01 -0.079 0.938
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C P_ID8987 P_ID89887 P_ID89888 P_ID93
## GDD_5C -0.909
## P_ID8987955 -0.600 0.550
## P_ID8988752 -0.600 0.550 0.476
## P_ID8988899 -0.600 0.550 0.476 0.476
## P_ID9340742 -0.600 0.550 0.476 0.476 0.476
## GDD_5C:P_ID8987 0.555 -0.618 -0.905 -0.439 -0.439 -0.439
## GDD_5C:P_ID89887 0.555 -0.618 -0.439 -0.905 -0.439 -0.439
## GDD_5C:P_ID89888 0.555 -0.618 -0.439 -0.439 -0.905 -0.439
## GDD_5C:P_ID9 0.555 -0.618 -0.439 -0.439 -0.439 -0.905
## GDD_5C:P_ID8987 GDD_5C:P_ID89887 GDD_5C:P_ID89888
## GDD_5C
## P_ID8987955
## P_ID8988752
## P_ID8988899
## P_ID9340742
## GDD_5C:P_ID8987
## GDD_5C:P_ID89887 0.492
## GDD_5C:P_ID89888 0.492 0.492
## GDD_5C:P_ID9 0.492 0.492 0.492
# For Populus
lmm_model_populus_shannon6 <- lmer(alphaDiv ~ GDD_5C + GDD_5C:Plant_ID + (1 | `Collection-Month`),
data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides"))
summary(lmm_model_populus_shannon6)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: alphaDiv ~ GDD_5C + GDD_5C:Plant_ID + (1 | `Collection-Month`)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides")
##
## REML criterion at convergence: 145.5
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.1818 -0.3016 -0.0013 0.5909 1.4828
##
## Random effects:
## Groups Name Variance Std.Dev.
## Collection-Month (Intercept) 0.05403 0.2324
## Residual 0.40822 0.6389
## Number of obs: 36, groups: Collection-Month, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 3.377e+00 3.678e-01 1.871e+00 9.181 0.0143 *
## GDD_5C 1.793e-04 2.667e-04 3.622e+00 0.672 0.5419
## GDD_5C:Plant_ID8987955 -1.861e-04 2.111e-04 2.656e+01 -0.881 0.3861
## GDD_5C:Plant_ID8988752 -5.558e-04 2.111e-04 2.656e+01 -2.632 0.0140 *
## GDD_5C:Plant_ID8988899 -1.037e-04 2.111e-04 2.656e+01 -0.491 0.6273
## GDD_5C:Plant_ID9340742 -9.977e-05 2.111e-04 2.656e+01 -0.473 0.6404
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C GDD_5C:P_ID8987 GDD_5C:P_ID89887
## GDD_5C -0.798
## GDD_5C:P_ID8987 0.022 -0.400
## GDD_5C:P_ID89887 0.022 -0.400 0.485
## GDD_5C:P_ID89888 0.022 -0.400 0.485 0.485
## GDD_5C:P_ID9 0.022 -0.400 0.485 0.485
## GDD_5C:P_ID89888
## GDD_5C
## GDD_5C:P_ID8987
## GDD_5C:P_ID89887
## GDD_5C:P_ID89888
## GDD_5C:P_ID9 0.485
# For Populus
lmm_model_populus_shannon7 <- lmer(sqrt(alphaDiv) ~ GDD_5C + GDD_5C:Plant_ID + (1 |
`Collection-Month`), data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species ==
"Populus_tremuloides"))
summary(lmm_model_populus_shannon7)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: sqrt(alphaDiv) ~ GDD_5C + GDD_5C:Plant_ID + (1 | `Collection-Month`)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides")
##
## REML criterion at convergence: 80.4
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.7365 -0.2189 0.0226 0.4283 1.3638
##
## Random effects:
## Groups Name Variance Std.Dev.
## Collection-Month (Intercept) 0.009126 0.09553
## Residual 0.045584 0.21350
## Number of obs: 36, groups: Collection-Month, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 1.821e+00 1.384e-01 2.103e+00 13.156 0.0047 **
## GDD_5C 5.376e-05 9.738e-05 3.626e+00 0.552 0.6132
## GDD_5C:Plant_ID8987955 -5.063e-05 7.057e-05 2.663e+01 -0.717 0.4794
## GDD_5C:Plant_ID8988752 -1.833e-04 7.057e-05 2.663e+01 -2.598 0.0151 *
## GDD_5C:Plant_ID8988899 -2.796e-05 7.057e-05 2.663e+01 -0.396 0.6951
## GDD_5C:Plant_ID9340742 -2.866e-05 7.057e-05 2.663e+01 -0.406 0.6879
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C GDD_5C:P_ID8987 GDD_5C:P_ID89887
## GDD_5C -0.819
## GDD_5C:P_ID8987 0.020 -0.367
## GDD_5C:P_ID89887 0.020 -0.367 0.485
## GDD_5C:P_ID89888 0.020 -0.367 0.485 0.485
## GDD_5C:P_ID9 0.020 -0.367 0.485 0.485
## GDD_5C:P_ID89888
## GDD_5C
## GDD_5C:P_ID8987
## GDD_5C:P_ID89887
## GDD_5C:P_ID89888
## GDD_5C:P_ID9 0.485
# For Populus
lmm_model_populus_shannon8 <- lmer(log(alphaDiv) ~ GDD_5C + GDD_5C:Plant_ID + (1 |
`Collection-Month`), data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species ==
"Populus_tremuloides"))
summary(lmm_model_populus_shannon8)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: log(alphaDiv) ~ GDD_5C + GDD_5C:Plant_ID + (1 | `Collection-Month`)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides")
##
## REML criterion at convergence: 105.7
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -4.2259 -0.1194 0.1110 0.2867 1.1848
##
## Random effects:
## Groups Name Variance Std.Dev.
## Collection-Month (Intercept) 0.02531 0.1591
## Residual 0.10482 0.3238
## Number of obs: 36, groups: Collection-Month, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 1.177e+00 2.230e-01 2.218e+00 5.277 0.0272 *
## GDD_5C 6.591e-05 1.547e-04 3.631e+00 0.426 0.6941
## GDD_5C:Plant_ID8987955 -5.532e-05 1.070e-04 2.667e+01 -0.517 0.6095
## GDD_5C:Plant_ID8988752 -2.622e-04 1.070e-04 2.667e+01 -2.450 0.0211 *
## GDD_5C:Plant_ID8988899 -3.024e-05 1.070e-04 2.667e+01 -0.283 0.7797
## GDD_5C:Plant_ID9340742 -3.337e-05 1.070e-04 2.667e+01 -0.312 0.7576
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C GDD_5C:P_ID8987 GDD_5C:P_ID89887
## GDD_5C -0.828
## GDD_5C:P_ID8987 0.019 -0.351
## GDD_5C:P_ID89887 0.019 -0.351 0.486
## GDD_5C:P_ID89888 0.019 -0.351 0.486 0.486
## GDD_5C:P_ID9 0.019 -0.351 0.486 0.486
## GDD_5C:P_ID89888
## GDD_5C
## GDD_5C:P_ID8987
## GDD_5C:P_ID89887
## GDD_5C:P_ID89888
## GDD_5C:P_ID9 0.486
# For Populus
lmm_model_populus_shannon9 <- lmer(I(alphaDiv^2) ~ GDD_5C + GDD_5C:Plant_ID + (1 |
`Collection-Month`), data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species ==
"Populus_tremuloides"))
summary(lmm_model_populus_shannon9)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: I(alphaDiv^2) ~ GDD_5C + GDD_5C:Plant_ID + (1 | `Collection-Month`)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides")
##
## REML criterion at convergence: 248.3
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.33967 -0.40245 -0.02526 0.67256 1.78657
##
## Random effects:
## Groups Name Variance Std.Dev.
## Collection-Month (Intercept) 0.1264 0.3556
## Residual 13.2528 3.6404
## Number of obs: 36, groups: Collection-Month, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 11.9647014 1.4832117 1.1539422 8.067 0.059 .
## GDD_5C 0.0010933 0.0012121 3.5026752 0.902 0.425
## GDD_5C:Plant_ID8987955 -0.0012778 0.0012020 26.2925858 -1.063 0.297
## GDD_5C:Plant_ID8988752 -0.0030048 0.0012020 26.2925858 -2.500 0.019 *
## GDD_5C:Plant_ID8988899 -0.0007262 0.0012020 26.2925858 -0.604 0.551
## GDD_5C:Plant_ID9340742 -0.0006349 0.0012020 26.2925858 -0.528 0.602
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C GDD_5C:P_ID8987 GDD_5C:P_ID89887
## GDD_5C -0.719
## GDD_5C:P_ID8987 0.026 -0.498
## GDD_5C:P_ID89887 0.026 -0.498 0.484
## GDD_5C:P_ID89888 0.026 -0.498 0.484 0.484
## GDD_5C:P_ID9 0.026 -0.498 0.484 0.484
## GDD_5C:P_ID89888
## GDD_5C
## GDD_5C:P_ID8987
## GDD_5C:P_ID89887
## GDD_5C:P_ID89888
## GDD_5C:P_ID9 0.484
# For Populus
lmm_model_populus_shannon10 <- lmer((1/alphaDiv) ~ GDD_5C + GDD_5C:Plant_ID + (1 |
`Collection-Month`), data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species ==
"Populus_tremuloides"))
summary(lmm_model_populus_shannon10)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: (1/alphaDiv) ~ GDD_5C + GDD_5C:Plant_ID + (1 | `Collection-Month`)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides")
##
## REML criterion at convergence: 95
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.1249 -0.2442 0.0005 0.0878 4.6960
##
## Random effects:
## Groups Name Variance Std.Dev.
## Collection-Month (Intercept) 0.0170 0.1304
## Residual 0.0735 0.2711
## Number of obs: 36, groups: Collection-Month, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 3.352e-01 1.841e-01 2.190e+00 1.821 0.1991
## GDD_5C -2.895e-05 1.281e-04 3.628e+00 -0.226 0.8334
## GDD_5C:Plant_ID8987955 1.658e-05 8.962e-05 2.666e+01 0.185 0.8546
## GDD_5C:Plant_ID8988752 1.820e-04 8.962e-05 2.666e+01 2.031 0.0523 .
## GDD_5C:Plant_ID8988899 8.809e-06 8.962e-05 2.666e+01 0.098 0.9224
## GDD_5C:Plant_ID9340742 1.161e-05 8.962e-05 2.666e+01 0.130 0.8979
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C GDD_5C:P_ID8987 GDD_5C:P_ID89887
## GDD_5C -0.826
## GDD_5C:P_ID8987 0.019 -0.354
## GDD_5C:P_ID89887 0.019 -0.354 0.486
## GDD_5C:P_ID89888 0.019 -0.354 0.486 0.486
## GDD_5C:P_ID9 0.019 -0.354 0.486 0.486
## GDD_5C:P_ID89888
## GDD_5C
## GDD_5C:P_ID8987
## GDD_5C:P_ID89887
## GDD_5C:P_ID89888
## GDD_5C:P_ID9 0.486
# For Populus
lmm_model_populus_shannon11 <- lmer(alphaDiv ~ GDD_5C + (1 | Plant_ID), data = subset(asv_scaled_noPlants_Phen_filt_LMM,
Species == "Populus_tremuloides"))
summary(lmm_model_populus_shannon11)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: alphaDiv ~ GDD_5C + (1 | Plant_ID)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides")
##
## REML criterion at convergence: 92.2
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -4.0663 -0.2285 0.0879 0.6363 1.4271
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0.01493 0.1222
## Residual 0.47466 0.6890
## Number of obs: 36, groups: Plant_ID, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 3.424e+00 2.747e-01 3.113e+01 12.465 1.22e-13 ***
## GDD_5C -2.399e-05 1.701e-04 3.011e+01 -0.141 0.889
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## GDD_5C -0.886
# For Populus
lmm_model_populus_shannon12 <- lmer(log(alphaDiv) ~ GDD_5C + (1 | Plant_ID), data = subset(asv_scaled_noPlants_Phen_filt_LMM,
Species == "Populus_tremuloides"))
summary(lmm_model_populus_shannon12)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: log(alphaDiv) ~ GDD_5C + (1 | Plant_ID)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides")
##
## REML criterion at convergence: 47
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -5.1429 -0.0268 0.1758 0.4499 0.7844
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0.004557 0.06751
## Residual 0.125441 0.35418
## Number of obs: 36, groups: Plant_ID, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 1.207e+00 1.416e-01 3.080e+01 8.524 1.32e-09 ***
## GDD_5C -1.885e-05 8.745e-05 3.001e+01 -0.216 0.831
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## GDD_5C -0.884
# For Populus
lmm_model_populus_shannon13 <- lmer((1/alphaDiv) ~ GDD_5C + (1 | Plant_ID), data = subset(asv_scaled_noPlants_Phen_filt_LMM,
Species == "Populus_tremuloides"))
summary(lmm_model_populus_shannon13)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: (1/alphaDiv) ~ GDD_5C + (1 | Plant_ID)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides")
##
## REML criterion at convergence: 33.4
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -0.3628 -0.2815 -0.1715 -0.0657 5.6278
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0.001446 0.03802
## Residual 0.085096 0.29171
## Number of obs: 36, groups: Plant_ID, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 3.166e-01 1.152e-01 3.175e+01 2.747 0.00982 **
## GDD_5C 1.787e-05 7.202e-05 2.994e+01 0.248 0.80572
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## GDD_5C -0.895
# For Populus
lmm_model_populus_shannon14 <- lmer(I(alphaDiv^2) ~ GDD_5C + (1 | Plant_ID), data = subset(asv_scaled_noPlants_Phen_filt_LMM,
Species == "Populus_tremuloides"))
summary(lmm_model_populus_shannon14)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: I(alphaDiv^2) ~ GDD_5C + (1 | Plant_ID)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides")
##
## REML criterion at convergence: 207.7
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.03828 -0.43731 0.04456 0.70366 1.99567
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0.1624 0.403
## Residual 14.4035 3.795
## Number of obs: 36, groups: Plant_ID, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 1.204e+01 1.494e+00 3.218e+01 8.063 3.18e-09 ***
## GDD_5C -6.037e-05 9.370e-04 3.023e+01 -0.064 0.949
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## GDD_5C -0.898
# For Populus
lmm_model_populus_shannon15 <- lmer(sqrt(alphaDiv) ~ GDD_5C + (1 | Plant_ID), data = subset(asv_scaled_noPlants_Phen_filt_LMM,
Species == "Populus_tremuloides"))
summary(lmm_model_populus_shannon15)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: sqrt(alphaDiv) ~ GDD_5C + (1 | Plant_ID)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides")
##
## REML criterion at convergence: 18.6
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -4.6496 -0.1290 0.1144 0.5618 1.1004
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0.002058 0.04537
## Residual 0.054310 0.23305
## Number of obs: 36, groups: Plant_ID, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 1.841e+00 9.329e-02 3.075e+01 19.739 <2e-16 ***
## GDD_5C -1.046e-05 5.754e-05 3.005e+01 -0.182 0.857
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## GDD_5C -0.883
# For Populus
lmm_model_populus_shannon16 <- lmer(alphaDiv ~ GDD_5C + GDD_5C:Plant_ID + (1 | Plant_ID),
data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides"))
## boundary (singular) fit: see help('isSingular')
summary(lmm_model_populus_shannon16)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: alphaDiv ~ GDD_5C + GDD_5C:Plant_ID + (1 | Plant_ID)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides")
##
## REML criterion at convergence: 146
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.4568 -0.2306 0.0477 0.6122 1.4565
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0.0000 0.0000
## Residual 0.4407 0.6638
## Number of obs: 36, groups: Plant_ID, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 3.4152176 0.2594653 30.0000000 13.163 5.35e-14 ***
## GDD_5C 0.0001691 0.0002158 30.0000000 0.784 0.4394
## GDD_5C:Plant_ID8987955 -0.0001872 0.0002192 30.0000000 -0.854 0.3998
## GDD_5C:Plant_ID8988752 -0.0005569 0.0002192 30.0000000 -2.541 0.0165 *
## GDD_5C:Plant_ID8988899 -0.0001048 0.0002192 30.0000000 -0.478 0.6359
## GDD_5C:Plant_ID9340742 -0.0001009 0.0002192 30.0000000 -0.460 0.6486
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C GDD_5C:P_ID8987 GDD_5C:P_ID89887
## GDD_5C -0.708
## GDD_5C:P_ID8987 0.026 -0.510
## GDD_5C:P_ID89887 0.026 -0.510 0.484
## GDD_5C:P_ID89888 0.026 -0.510 0.484 0.484
## GDD_5C:P_ID9 0.026 -0.510 0.484 0.484
## GDD_5C:P_ID89888
## GDD_5C
## GDD_5C:P_ID8987
## GDD_5C:P_ID89887
## GDD_5C:P_ID89888
## GDD_5C:P_ID9 0.484
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
# For Populus
lmm_model_populus_shannon17 <- lmer(log(alphaDiv) ~ GDD_5C + GDD_5C:Plant_ID + (1 |
Plant_ID), data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides"))
## boundary (singular) fit: see help('isSingular')
summary(lmm_model_populus_shannon17)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: log(alphaDiv) ~ GDD_5C + GDD_5C:Plant_ID + (1 | Plant_ID)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides")
##
## REML criterion at convergence: 106.9
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -4.5514 -0.0851 0.1241 0.3395 1.2112
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0.0000 0.000
## Residual 0.1197 0.346
## Number of obs: 36, groups: Plant_ID, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 1.204e+00 1.352e-01 3.000e+01 8.904 6.35e-10 ***
## GDD_5C 5.906e-05 1.125e-04 3.000e+01 0.525 0.6034
## GDD_5C:Plant_ID8987955 -5.590e-05 1.142e-04 3.000e+01 -0.489 0.6281
## GDD_5C:Plant_ID8988752 -2.628e-04 1.142e-04 3.000e+01 -2.301 0.0285 *
## GDD_5C:Plant_ID8988899 -3.082e-05 1.142e-04 3.000e+01 -0.270 0.7891
## GDD_5C:Plant_ID9340742 -3.395e-05 1.142e-04 3.000e+01 -0.297 0.7683
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C GDD_5C:P_ID8987 GDD_5C:P_ID89887
## GDD_5C -0.708
## GDD_5C:P_ID8987 0.026 -0.510
## GDD_5C:P_ID89887 0.026 -0.510 0.484
## GDD_5C:P_ID89888 0.026 -0.510 0.484 0.484
## GDD_5C:P_ID9 0.026 -0.510 0.484 0.484
## GDD_5C:P_ID89888
## GDD_5C
## GDD_5C:P_ID8987
## GDD_5C:P_ID89887
## GDD_5C:P_ID89888
## GDD_5C:P_ID9 0.484
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
# For Populus
lmm_model_populus_shannon18 <- lmer((1/alphaDiv) ~ GDD_5C + GDD_5C:Plant_ID + (1 |
Plant_ID), data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides"))
## boundary (singular) fit: see help('isSingular')
summary(lmm_model_populus_shannon18)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: (1/alphaDiv) ~ GDD_5C + GDD_5C:Plant_ID + (1 | Plant_ID)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides")
##
## REML criterion at convergence: 96.1
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.1985 -0.1364 -0.0810 0.0330 4.9871
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0.00000 0.0000
## Residual 0.08348 0.2889
## Number of obs: 36, groups: Plant_ID, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 3.189e-01 1.129e-01 3.000e+01 2.824 0.00835 **
## GDD_5C -2.727e-05 9.393e-05 3.000e+01 -0.290 0.77362
## GDD_5C:Plant_ID8987955 1.720e-05 9.539e-05 3.000e+01 0.180 0.85815
## GDD_5C:Plant_ID8988752 1.826e-04 9.539e-05 3.000e+01 1.914 0.06515 .
## GDD_5C:Plant_ID8988899 9.422e-06 9.539e-05 3.000e+01 0.099 0.92197
## GDD_5C:Plant_ID9340742 1.223e-05 9.539e-05 3.000e+01 0.128 0.89887
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C GDD_5C:P_ID8987 GDD_5C:P_ID89887
## GDD_5C -0.708
## GDD_5C:P_ID8987 0.026 -0.510
## GDD_5C:P_ID89887 0.026 -0.510 0.484
## GDD_5C:P_ID89888 0.026 -0.510 0.484 0.484
## GDD_5C:P_ID9 0.026 -0.510 0.484 0.484
## GDD_5C:P_ID89888
## GDD_5C
## GDD_5C:P_ID8987
## GDD_5C:P_ID89887
## GDD_5C:P_ID89888
## GDD_5C:P_ID9 0.484
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
# For Populus
lmm_model_populus_shannon19 <- lmer(I(alphaDiv^2) ~ GDD_5C + GDD_5C:Plant_ID + (1 |
Plant_ID), data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides"))
## boundary (singular) fit: see help('isSingular')
summary(lmm_model_populus_shannon19)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: I(alphaDiv^2) ~ GDD_5C + GDD_5C:Plant_ID + (1 | Plant_ID)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides")
##
## REML criterion at convergence: 248.3
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.37121 -0.39554 -0.02129 0.68251 1.78695
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0.00 0.000
## Residual 13.33 3.651
## Number of obs: 36, groups: Plant_ID, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 11.9798979 1.4271934 30.0000000 8.394 2.28e-09 ***
## GDD_5C 0.0010922 0.0011872 30.0000000 0.920 0.3649
## GDD_5C:Plant_ID8987955 -0.0012790 0.0012055 30.0000000 -1.061 0.2972
## GDD_5C:Plant_ID8988752 -0.0030061 0.0012055 30.0000000 -2.494 0.0184 *
## GDD_5C:Plant_ID8988899 -0.0007275 0.0012055 30.0000000 -0.603 0.5507
## GDD_5C:Plant_ID9340742 -0.0006362 0.0012055 30.0000000 -0.528 0.6016
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C GDD_5C:P_ID8987 GDD_5C:P_ID89887
## GDD_5C -0.708
## GDD_5C:P_ID8987 0.026 -0.510
## GDD_5C:P_ID89887 0.026 -0.510 0.484
## GDD_5C:P_ID89888 0.026 -0.510 0.484 0.484
## GDD_5C:P_ID9 0.026 -0.510 0.484 0.484
## GDD_5C:P_ID89888
## GDD_5C
## GDD_5C:P_ID8987
## GDD_5C:P_ID89887
## GDD_5C:P_ID89888
## GDD_5C:P_ID9 0.484
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
# For Populus
lmm_model_populus_shannon20 <- lmer(sqrt(alphaDiv) ~ GDD_5C + GDD_5C:Plant_ID + (1 |
Plant_ID), data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides"))
## boundary (singular) fit: see help('isSingular')
summary(lmm_model_populus_shannon20)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: sqrt(alphaDiv) ~ GDD_5C + GDD_5C:Plant_ID + (1 | Plant_ID)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides")
##
## REML criterion at convergence: 81.3
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -4.0609 -0.1537 0.0724 0.4736 1.3186
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0.00000 0.0000
## Residual 0.05099 0.2258
## Number of obs: 36, groups: Plant_ID, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 1.839e+00 8.825e-02 3.000e+01 20.837 <2e-16 ***
## GDD_5C 4.887e-05 7.341e-05 3.000e+01 0.666 0.5107
## GDD_5C:Plant_ID8987955 -5.101e-05 7.455e-05 3.000e+01 -0.684 0.4991
## GDD_5C:Plant_ID8988752 -1.837e-04 7.455e-05 3.000e+01 -2.464 0.0197 *
## GDD_5C:Plant_ID8988899 -2.834e-05 7.455e-05 3.000e+01 -0.380 0.7065
## GDD_5C:Plant_ID9340742 -2.904e-05 7.455e-05 3.000e+01 -0.390 0.6996
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C GDD_5C:P_ID8987 GDD_5C:P_ID89887
## GDD_5C -0.708
## GDD_5C:P_ID8987 0.026 -0.510
## GDD_5C:P_ID89887 0.026 -0.510 0.484
## GDD_5C:P_ID89888 0.026 -0.510 0.484 0.484
## GDD_5C:P_ID9 0.026 -0.510 0.484 0.484
## GDD_5C:P_ID89888
## GDD_5C
## GDD_5C:P_ID8987
## GDD_5C:P_ID89887
## GDD_5C:P_ID89888
## GDD_5C:P_ID9 0.484
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
# For Populus
lmm_model_populus_shannon21 <- lmer(alphaDiv ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID +
(1 | Plant_ID), data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides"))
## Warning in as_lmerModLT(model, devfun): Model may not have converged with 1
## eigenvalue close to zero: 1.6e-09
summary(lmm_model_populus_shannon21)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: alphaDiv ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID + (1 | Plant_ID)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides")
##
## REML criterion at convergence: 140.3
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.3033 -0.2640 0.0572 0.5693 1.2115
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0.0803 0.2834
## Residual 0.4940 0.7028
## Number of obs: 36, groups: Plant_ID, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 3.530e+00 6.544e-01 2.600e+01 5.393 1.19e-05 ***
## GDD_5C 1.018e-04 3.831e-04 2.600e+01 0.266 0.793
## Plant_ID8987955 -8.518e-03 9.455e-01 2.600e+01 -0.009 0.993
## Plant_ID8988752 1.865e-01 9.455e-01 2.600e+01 0.197 0.845
## Plant_ID8988899 -2.474e-01 9.455e-01 2.600e+01 -0.262 0.796
## Plant_ID9340742 -5.144e-01 9.455e-01 2.600e+01 -0.544 0.591
## GDD_5C:Plant_ID8987955 -1.799e-04 5.463e-04 2.600e+01 -0.329 0.745
## GDD_5C:Plant_ID8988752 -6.601e-04 5.463e-04 2.600e+01 -1.208 0.238
## GDD_5C:Plant_ID8988899 3.794e-05 5.463e-04 2.600e+01 0.069 0.945
## GDD_5C:Plant_ID9340742 1.933e-04 5.463e-04 2.600e+01 0.354 0.726
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C P_ID8987 P_ID89887 P_ID89888 P_ID93
## GDD_5C -0.818
## P_ID8987955 -0.692 0.566
## P_ID8988752 -0.692 0.566 0.479
## P_ID8988899 -0.692 0.566 0.479 0.479
## P_ID9340742 -0.692 0.566 0.479 0.479 0.479
## GDD_5C:P_ID8987 0.573 -0.701 -0.820 -0.397 -0.397 -0.397
## GDD_5C:P_ID89887 0.573 -0.701 -0.397 -0.820 -0.397 -0.397
## GDD_5C:P_ID89888 0.573 -0.701 -0.397 -0.397 -0.820 -0.397
## GDD_5C:P_ID9 0.573 -0.701 -0.397 -0.397 -0.397 -0.820
## GDD_5C:P_ID8987 GDD_5C:P_ID89887 GDD_5C:P_ID89888
## GDD_5C
## P_ID8987955
## P_ID8988752
## P_ID8988899
## P_ID9340742
## GDD_5C:P_ID8987
## GDD_5C:P_ID89887 0.492
## GDD_5C:P_ID89888 0.492 0.492
## GDD_5C:P_ID9 0.492 0.492 0.492
# For Populus
lmm_model_populus_shannon22 <- lmer(log(alphaDiv) ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID +
(1 | Plant_ID), data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides"))
## Warning in as_lmerModLT(model, devfun): Model may not have converged with 1
## eigenvalue close to zero: 3.3e-10
summary(lmm_model_populus_shannon22)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: log(alphaDiv) ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID + (1 | Plant_ID)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides")
##
## REML criterion at convergence: 107
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -4.2608 -0.0996 0.1055 0.3279 1.1515
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0.004434 0.06659
## Residual 0.137111 0.37029
## Number of obs: 36, groups: Plant_ID, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 1.245e+00 3.178e-01 2.600e+01 3.916 0.000582 ***
## GDD_5C 3.517e-05 2.018e-04 2.600e+01 0.174 0.863009
## Plant_ID8987955 1.148e-02 4.609e-01 2.600e+01 0.025 0.980327
## Plant_ID8988752 -6.242e-03 4.609e-01 2.600e+01 -0.014 0.989299
## Plant_ID8988899 -5.143e-02 4.609e-01 2.600e+01 -0.112 0.912004
## Plant_ID9340742 -1.610e-01 4.609e-01 2.600e+01 -0.349 0.729678
## GDD_5C:Plant_ID8987955 -6.151e-05 2.878e-04 2.600e+01 -0.214 0.832418
## GDD_5C:Plant_ID8988752 -2.584e-04 2.878e-04 2.600e+01 -0.898 0.377583
## GDD_5C:Plant_ID8988899 -7.713e-07 2.878e-04 2.600e+01 -0.003 0.997882
## GDD_5C:Plant_ID9340742 5.822e-05 2.878e-04 2.600e+01 0.202 0.841266
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C P_ID8987 P_ID89887 P_ID89888 P_ID93
## GDD_5C -0.887
## P_ID8987955 -0.690 0.612
## P_ID8988752 -0.690 0.612 0.476
## P_ID8988899 -0.690 0.612 0.476 0.476
## P_ID9340742 -0.690 0.612 0.476 0.476 0.476
## GDD_5C:P_ID8987 0.622 -0.701 -0.886 -0.429 -0.429 -0.429
## GDD_5C:P_ID89887 0.622 -0.701 -0.429 -0.886 -0.429 -0.429
## GDD_5C:P_ID89888 0.622 -0.701 -0.429 -0.429 -0.886 -0.429
## GDD_5C:P_ID9 0.622 -0.701 -0.429 -0.429 -0.429 -0.886
## GDD_5C:P_ID8987 GDD_5C:P_ID89887 GDD_5C:P_ID89888
## GDD_5C
## P_ID8987955
## P_ID8988752
## P_ID8988899
## P_ID9340742
## GDD_5C:P_ID8987
## GDD_5C:P_ID89887 0.492
## GDD_5C:P_ID89888 0.492 0.492
## GDD_5C:P_ID9 0.492 0.492 0.492
# For Populus
lmm_model_populus_shannon23 <- lmer(sqrt(alphaDiv) ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID +
(1 | Plant_ID), data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides"))
summary(lmm_model_populus_shannon23)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: sqrt(alphaDiv) ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID + (1 | Plant_ID)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides")
##
## REML criterion at convergence: 84.6
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.8355 -0.1506 0.1004 0.4411 1.1378
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0.0006138 0.02477
## Residual 0.0578698 0.24056
## Number of obs: 36, groups: Plant_ID, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 1.871e+00 2.034e-01 2.506e-07 9.198 1.000
## GDD_5C 3.003e-05 1.311e-04 2.600e+01 0.229 0.821
## Plant_ID8987955 4.252e-03 2.952e-01 2.779e-07 0.014 1.000
## Plant_ID8988752 3.217e-02 2.952e-01 2.779e-07 0.109 1.000
## Plant_ID8988899 -5.706e-02 2.952e-01 2.779e-07 -0.193 1.000
## Plant_ID9340742 -1.428e-01 2.952e-01 2.779e-07 -0.484 1.000
## GDD_5C:Plant_ID8987955 -5.271e-05 1.870e-04 2.600e+01 -0.282 0.780
## GDD_5C:Plant_ID8988752 -2.012e-04 1.870e-04 2.600e+01 -1.076 0.292
## GDD_5C:Plant_ID8988899 4.720e-06 1.870e-04 2.600e+01 0.025 0.980
## GDD_5C:Plant_ID9340742 5.261e-05 1.870e-04 2.600e+01 0.281 0.781
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C P_ID8987 P_ID89887 P_ID89888 P_ID93
## GDD_5C -0.900
## P_ID8987955 -0.689 0.620
## P_ID8988752 -0.689 0.620 0.475
## P_ID8988899 -0.689 0.620 0.475 0.475
## P_ID9340742 -0.689 0.620 0.475 0.475 0.475
## GDD_5C:P_ID8987 0.631 -0.701 -0.899 -0.435 -0.435 -0.435
## GDD_5C:P_ID89887 0.631 -0.701 -0.435 -0.899 -0.435 -0.435
## GDD_5C:P_ID89888 0.631 -0.701 -0.435 -0.435 -0.899 -0.435
## GDD_5C:P_ID9 0.631 -0.701 -0.435 -0.435 -0.435 -0.899
## GDD_5C:P_ID8987 GDD_5C:P_ID89887 GDD_5C:P_ID89888
## GDD_5C
## P_ID8987955
## P_ID8988752
## P_ID8988899
## P_ID9340742
## GDD_5C:P_ID8987
## GDD_5C:P_ID89887 0.492
## GDD_5C:P_ID89888 0.492 0.492
## GDD_5C:P_ID9 0.492 0.492 0.492
# For Populus
lmm_model_populus_shannon24 <- lmer(alphaDiv ~ GDD_5C + Plant_ID + (1 | Plant_ID),
data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides"))
## Warning in as_lmerModLT(model, devfun): Model may not have converged with 1
## eigenvalue close to zero: 1.7e-11
summary(lmm_model_populus_shannon24)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: alphaDiv ~ GDD_5C + Plant_ID + (1 | Plant_ID)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides")
##
## REML criterion at convergence: 89.3
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.4973 -0.2806 0.0581 0.5547 1.5120
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0.004825 0.06947
## Residual 0.475168 0.68932
## Number of obs: 36, groups: Plant_ID, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 3.698e+00 3.475e-01 3.000e+01 10.643 1.05e-11 ***
## GDD_5C -1.914e-05 1.702e-04 3.000e+01 -0.112 0.9112
## Plant_ID8987955 -2.623e-01 3.701e-01 3.000e+01 -0.709 0.4840
## Plant_ID8988752 -7.592e-01 3.701e-01 3.000e+01 -2.051 0.0491 *
## Plant_ID8988899 -1.874e-01 3.701e-01 3.000e+01 -0.506 0.6164
## Plant_ID9340742 -2.306e-01 3.701e-01 3.000e+01 -0.623 0.5380
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C P_ID8987 P_ID89887 P_ID89888
## GDD_5C -0.684
## P_ID8987955 -0.485 -0.020
## P_ID8988752 -0.485 -0.020 0.469
## P_ID8988899 -0.485 -0.020 0.469 0.469
## P_ID9340742 -0.485 -0.020 0.469 0.469 0.469
# For Populus
lmm_model_populus_shannon25 <- lmer((1/alphaDiv) ~ GDD_5C + Plant_ID + (1 | Plant_ID),
data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides"))
## Warning in as_lmerModLT(model, devfun): Model may not have converged with 1
## eigenvalue close to zero: 1.2e-10
summary(lmm_model_populus_shannon25)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: (1/alphaDiv) ~ GDD_5C + Plant_ID + (1 | Plant_ID)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides")
##
## REML criterion at convergence: 37.6
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.0082 -0.1789 -0.0478 0.0538 4.9899
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0.08053 0.2838
## Residual 0.08494 0.2915
## Number of obs: 36, groups: Plant_ID, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 2.530e-01 3.182e-01 3.000e+01 0.795 0.433
## GDD_5C 1.663e-05 7.198e-05 3.000e+01 0.231 0.819
## Plant_ID8987955 2.136e-02 4.287e-01 3.000e+01 0.050 0.961
## Plant_ID8988752 2.753e-01 4.287e-01 3.000e+01 0.642 0.526
## Plant_ID8988899 1.318e-02 4.287e-01 3.000e+01 0.031 0.976
## Plant_ID9340742 2.536e-02 4.287e-01 3.000e+01 0.059 0.953
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C P_ID8987 P_ID89887 P_ID89888
## GDD_5C -0.316
## P_ID8987955 -0.666 -0.007
## P_ID8988752 -0.666 -0.007 0.496
## P_ID8988899 -0.666 -0.007 0.496 0.496
## P_ID9340742 -0.666 -0.007 0.496 0.496 0.496
# For Populus
lmm_model_populus_shannon26 <- lmer(log(alphaDiv) ~ GDD_5C + Plant_ID + (1 | Plant_ID),
data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides"))
## Warning in as_lmerModLT(model, devfun): Model may not have converged with 1
## eigenvalue close to zero: 1.1e-09
summary(lmm_model_populus_shannon26)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: log(alphaDiv) ~ GDD_5C + Plant_ID + (1 | Plant_ID)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides")
##
## REML criterion at convergence: 49.3
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -4.5521 -0.1085 0.0615 0.3890 1.2811
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0.02118 0.1455
## Residual 0.12537 0.3541
## Number of obs: 36, groups: Plant_ID, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 1.317e+00 2.275e-01 3.000e+01 5.790 2.51e-06 ***
## GDD_5C -1.697e-05 8.745e-05 3.000e+01 -0.194 0.847
## Plant_ID8987955 -7.485e-02 2.756e-01 3.000e+01 -0.272 0.788
## Plant_ID8988752 -3.762e-01 2.756e-01 3.000e+01 -1.365 0.182
## Plant_ID8988899 -5.024e-02 2.756e-01 3.000e+01 -0.182 0.857
## Plant_ID9340742 -7.481e-02 2.756e-01 3.000e+01 -0.271 0.788
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C P_ID8987 P_ID89887 P_ID89888
## GDD_5C -0.537
## P_ID8987955 -0.580 -0.014
## P_ID8988752 -0.580 -0.014 0.485
## P_ID8988899 -0.580 -0.014 0.485 0.485
## P_ID9340742 -0.580 -0.014 0.485 0.485 0.485
# For Populus
lmm_model_populus_shannon27 <- lmer(sqrt(alphaDiv) ~ GDD_5C + Plant_ID + (1 | Plant_ID),
data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides"))
## Warning in as_lmerModLT(model, devfun): Model may not have converged with 1
## eigenvalue close to zero: 1.9e-09
summary(lmm_model_populus_shannon27)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: sqrt(alphaDiv) ~ GDD_5C + Plant_ID + (1 | Plant_ID)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides")
##
## REML criterion at convergence: 24.2
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -4.0738 -0.2009 0.0664 0.4989 1.4181
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0.009218 0.09601
## Residual 0.054321 0.23307
## Number of obs: 36, groups: Plant_ID, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 1.925e+00 1.499e-01 3.000e+01 12.845 1e-13 ***
## GDD_5C -9.031e-06 5.756e-05 3.000e+01 -0.157 0.876
## Plant_ID8987955 -6.997e-02 1.816e-01 3.000e+01 -0.385 0.703
## Plant_ID8988752 -2.561e-01 1.816e-01 3.000e+01 -1.410 0.169
## Plant_ID8988899 -4.853e-02 1.816e-01 3.000e+01 -0.267 0.791
## Plant_ID9340742 -6.524e-02 1.816e-01 3.000e+01 -0.359 0.722
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C P_ID8987 P_ID89887 P_ID89888
## GDD_5C -0.536
## P_ID8987955 -0.580 -0.014
## P_ID8988752 -0.580 -0.014 0.485
## P_ID8988899 -0.580 -0.014 0.485 0.485
## P_ID9340742 -0.580 -0.014 0.485 0.485 0.485
NOTE: Models WITHOUT Singularity issues: -
lmm_model_populus_shannon1 -
lmm_model_populus_shannon2 -
lmm_model_populus_shannon3 -
lmm_model_populus_shannon5 -
lmm_model_populus_shannon6 -
lmm_model_populus_shannon7 -
lmm_model_populus_shannon8 -
lmm_model_populus_shannon9 -
lmm_model_populus_shannon10 -
lmm_model_populus_shannon11 -
lmm_model_populus_shannon12 -
lmm_model_populus_shannon13 -
lmm_model_populus_shannon14 -
lmm_model_populus_shannon15
#-------------------------------------------------------------------------
## To be sure of my model, let's run formal diagnostics:
#-------------------------------------------------------------------------
# Formal Test of Normality (Shapiro-Wilks)
#-------------------------------------------------------------------------
shapiro.test(residuals(lmm_model_populus_shannon1)) # p=0.0.0006544 -> NOT Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_populus_shannon1)
## W = 0.89012, p-value = 0.001852
shapiro.test(residuals(lmm_model_populus_shannon2)) # p=5.856e-06 -> NOT Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_populus_shannon2)
## W = 0.80582, p-value = 2.13e-05
shapiro.test(residuals(lmm_model_populus_shannon3)) # p=6.719e-08 -> NOT Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_populus_shannon3)
## W = 0.69667, p-value = 2.509e-07
shapiro.test(residuals(lmm_model_populus_shannon4)) # p=0.364-> Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_populus_shannon4)
## W = 0.96765, p-value = 0.3649
shapiro.test(residuals(lmm_model_populus_shannon5)) # p=3.736e-10 -> NOT Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_populus_shannon5)
## W = 0.54013, p-value = 1.865e-09
shapiro.test(residuals(lmm_model_populus_shannon6)) # p=0.001089 -> NOT Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_populus_shannon6)
## W = 0.89935, p-value = 0.003275
shapiro.test(residuals(lmm_model_populus_shannon7)) # p=7.289e-06 -> NOT Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_populus_shannon7)
## W = 0.81412, p-value = 3.146e-05
shapiro.test(residuals(lmm_model_populus_shannon8)) # p=6.75e-08 -> NOT Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_populus_shannon8)
## W = 0.70655, p-value = 3.591e-07
shapiro.test(residuals(lmm_model_populus_shannon9)) # p=0.498 -> Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_populus_shannon9)
## W = 0.97209, p-value = 0.4852
shapiro.test(residuals(lmm_model_populus_shannon10)) # p=3.02e-10 -> NOT Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_populus_shannon10)
## W = 0.55354, p-value = 2.708e-09
shapiro.test(residuals(lmm_model_populus_shannon11)) # p=4.069e-05 -> NOT Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_populus_shannon11)
## W = 0.81949, p-value = 4.069e-05
shapiro.test(residuals(lmm_model_populus_shannon12)) # p=1.273e-09 -> NOT Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_populus_shannon12)
## W = 0.52612, p-value = 1.273e-09
shapiro.test(residuals(lmm_model_populus_shannon13)) # p=4.58e-12 -> NOT Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_populus_shannon13)
## W = 0.28482, p-value = 4.58e-12
shapiro.test(residuals(lmm_model_populus_shannon14)) # p=0.198 -> Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_populus_shannon14)
## W = 0.95884, p-value = 0.198
shapiro.test(residuals(lmm_model_populus_shannon15)) # p=1.697e-07 -> NOT Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_populus_shannon15)
## W = 0.68567, p-value = 1.697e-07
shapiro.test(residuals(lmm_model_populus_shannon16)) # p=0.001085 -> NOT Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_populus_shannon16)
## W = 0.88118, p-value = 0.001085
shapiro.test(residuals(lmm_model_populus_shannon17)) # p=6.729e-08 -> NOT Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_populus_shannon17)
## W = 0.65866, p-value = 6.729e-08
shapiro.test(residuals(lmm_model_populus_shannon18)) # p=3.019e-10 -> NOT Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_populus_shannon18)
## W = 0.47078, p-value = 3.019e-10
shapiro.test(residuals(lmm_model_populus_shannon19)) # p=0.4981 -> Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_populus_shannon19)
## W = 0.97251, p-value = 0.4981
shapiro.test(residuals(lmm_model_populus_shannon20)) # p=7.258e-06 -> NOT Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_populus_shannon20)
## W = 0.7819, p-value = 7.258e-06
shapiro.test(residuals(lmm_model_populus_shannon23))
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_populus_shannon23)
## W = 0.77694, p-value = 5.855e-06
shapiro.test(residuals(lmm_model_populus_shannon24))
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_populus_shannon24)
## W = 0.88362, p-value = 0.001254
shapiro.test(residuals(lmm_model_populus_shannon25))
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_populus_shannon25)
## W = 0.48014, p-value = 3.823e-10
shapiro.test(residuals(lmm_model_populus_shannon26))
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_populus_shannon26)
## W = 0.66308, p-value = 7.806e-08
shapiro.test(residuals(lmm_model_populus_shannon27))
##
## Shapiro-Wilk normality test
##
## data: residuals(lmm_model_populus_shannon27)
## W = 0.78187, p-value = 7.249e-06
NOTE: Models WITHOUT Singularity issues: -
lmm_model_populus_shannon1 -
lmm_model_populus_shannon2 -
lmm_model_populus_shannon3 -
lmm_model_populus_shannon5 -
lmm_model_populus_shannon6 -
lmm_model_populus_shannon7 -
lmm_model_populus_shannon8 -
lmm_model_populus_shannon9 -
lmm_model_populus_shannon10 -
lmm_model_populus_shannon11 -
lmm_model_populus_shannon12 -
lmm_model_populus_shannon13 -
lmm_model_populus_shannon14 -
lmm_model_populus_shannon15
#-------------------------------------------------------------------------
## Check Diagnostic Statistics/Assumptions
#-------------------------------------------------------------------------
check_model(lmm_model_populus_shannon1, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_populus_shannon2, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_populus_shannon3, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_populus_shannon4, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_populus_shannon5, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_populus_shannon6, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_populus_shannon7, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_populus_shannon8, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_populus_shannon9, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_populus_shannon10, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_populus_shannon11, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_populus_shannon12, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_populus_shannon13, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_populus_shannon14, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_populus_shannon15, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_populus_shannon16, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_populus_shannon17, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_populus_shannon18, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_populus_shannon19, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_populus_shannon20, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_populus_shannon21, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_populus_shannon22, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_populus_shannon23, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_populus_shannon24, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_populus_shannon25, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_populus_shannon26, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
check_model(lmm_model_populus_shannon27, check = c("pp_check", "normality", "vif",
"linearity", "homogeneity", "outliers"))
NOTE: Maybe lmm_model_populus_shannon6,
lmm_model_populus_shannon11, or
lmm_model_populus_shannon15…
BUT IF SINGULARITY ALLOWED: Also consider
lmm_model_populus_shannon16, &
lmm_model_populus_shannon20
…but hard to tell from check_model()…
#-------------------------------------------------------------------------
## Compare Model Fits with anova():
#-------------------------------------------------------------------------
# Compare 'model' with ANOVA model:
anova(lmm_model_populus_shannon1, lmm_model_populus_shannon2, lmm_model_populus_shannon3,
lmm_model_populus_shannon4, lmm_model_populus_shannon5, lmm_model_populus_shannon6,
lmm_model_populus_shannon7, lmm_model_populus_shannon8, lmm_model_populus_shannon9,
lmm_model_populus_shannon10, lmm_model_populus_shannon11, lmm_model_populus_shannon12,
lmm_model_populus_shannon13, lmm_model_populus_shannon14, lmm_model_populus_shannon15,
lmm_model_populus_shannon16, lmm_model_populus_shannon17, lmm_model_populus_shannon18,
lmm_model_populus_shannon19, lmm_model_populus_shannon20, lmm_model_populus_shannon21,
lmm_model_populus_shannon22, lmm_model_populus_shannon23, lmm_model_populus_shannon24,
lmm_model_populus_shannon25, lmm_model_populus_shannon26, lmm_model_populus_shannon27)
## refitting model(s) with ML (instead of REML)
## Warning in optwrap(optimizer, devfun, x@theta, lower = x@lower, calc.derivs =
## TRUE, : convergence code 3 from bobyqa: bobyqa -- a trust region step failed to
## reduce q
## Data: subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides")
## Models:
## lmm_model_populus_shannon11: alphaDiv ~ GDD_5C + (1 | Plant_ID)
## lmm_model_populus_shannon12: log(alphaDiv) ~ GDD_5C + (1 | Plant_ID)
## lmm_model_populus_shannon13: (1/alphaDiv) ~ GDD_5C + (1 | Plant_ID)
## lmm_model_populus_shannon14: I(alphaDiv^2) ~ GDD_5C + (1 | Plant_ID)
## lmm_model_populus_shannon15: sqrt(alphaDiv) ~ GDD_5C + (1 | Plant_ID)
## lmm_model_populus_shannon6: alphaDiv ~ GDD_5C + GDD_5C:Plant_ID + (1 | `Collection-Month`)
## lmm_model_populus_shannon7: sqrt(alphaDiv) ~ GDD_5C + GDD_5C:Plant_ID + (1 | `Collection-Month`)
## lmm_model_populus_shannon8: log(alphaDiv) ~ GDD_5C + GDD_5C:Plant_ID + (1 | `Collection-Month`)
## lmm_model_populus_shannon9: I(alphaDiv^2) ~ GDD_5C + GDD_5C:Plant_ID + (1 | `Collection-Month`)
## lmm_model_populus_shannon10: (1/alphaDiv) ~ GDD_5C + GDD_5C:Plant_ID + (1 | `Collection-Month`)
## lmm_model_populus_shannon16: alphaDiv ~ GDD_5C + GDD_5C:Plant_ID + (1 | Plant_ID)
## lmm_model_populus_shannon17: log(alphaDiv) ~ GDD_5C + GDD_5C:Plant_ID + (1 | Plant_ID)
## lmm_model_populus_shannon18: (1/alphaDiv) ~ GDD_5C + GDD_5C:Plant_ID + (1 | Plant_ID)
## lmm_model_populus_shannon19: I(alphaDiv^2) ~ GDD_5C + GDD_5C:Plant_ID + (1 | Plant_ID)
## lmm_model_populus_shannon20: sqrt(alphaDiv) ~ GDD_5C + GDD_5C:Plant_ID + (1 | Plant_ID)
## lmm_model_populus_shannon24: alphaDiv ~ GDD_5C + Plant_ID + (1 | Plant_ID)
## lmm_model_populus_shannon25: (1/alphaDiv) ~ GDD_5C + Plant_ID + (1 | Plant_ID)
## lmm_model_populus_shannon26: log(alphaDiv) ~ GDD_5C + Plant_ID + (1 | Plant_ID)
## lmm_model_populus_shannon27: sqrt(alphaDiv) ~ GDD_5C + Plant_ID + (1 | Plant_ID)
## lmm_model_populus_shannon1: alphaDiv ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID + (1 | `Collection-Month`)
## lmm_model_populus_shannon2: sqrt(alphaDiv) ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID + (1 | `Collection-Month`)
## lmm_model_populus_shannon3: log(alphaDiv) ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID + (1 | `Collection-Month`)
## lmm_model_populus_shannon4: I(alphaDiv^2) ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID + (1 | `Collection-Month`)
## lmm_model_populus_shannon5: (1/alphaDiv) ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID + (1 | `Collection-Month`)
## lmm_model_populus_shannon21: alphaDiv ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID + (1 | Plant_ID)
## lmm_model_populus_shannon22: log(alphaDiv) ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID + (1 | Plant_ID)
## lmm_model_populus_shannon23: sqrt(alphaDiv) ~ GDD_5C + Plant_ID + GDD_5C:Plant_ID + (1 | Plant_ID)
## npar AIC BIC logLik deviance Chisq Df
## lmm_model_populus_shannon11 4 82.227 88.561 -37.113 74.227
## lmm_model_populus_shannon12 4 34.458 40.792 -13.229 26.458 47.769 0
## lmm_model_populus_shannon13 4 19.916 26.250 -5.958 11.916 14.543 0
## lmm_model_populus_shannon14 4 204.477 210.811 -98.239 196.477 0.000 0
## lmm_model_populus_shannon15 4 4.368 10.702 1.816 -3.632 200.110 0
## lmm_model_populus_shannon6 8 82.101 94.769 -33.051 66.101 0.000 4
## lmm_model_populus_shannon7 8 4.362 17.030 5.819 -11.638 77.739 0
## lmm_model_populus_shannon8 8 34.933 47.601 -9.466 18.933 0.000 0
## lmm_model_populus_shannon9 8 204.850 217.518 -94.425 188.850 0.000 0
## lmm_model_populus_shannon10 8 22.010 34.678 -3.005 6.010 182.840 0
## lmm_model_populus_shannon16 8 82.101 94.769 -33.051 66.101 0.000 0
## lmm_model_populus_shannon17 8 35.180 47.848 -9.590 19.180 46.921 0
## lmm_model_populus_shannon18 8 22.205 34.873 -3.103 6.205 12.975 0
## lmm_model_populus_shannon19 8 204.850 217.518 -94.425 188.850 0.000 0
## lmm_model_populus_shannon20 8 4.456 17.124 5.772 -11.544 200.393 0
## lmm_model_populus_shannon24 8 84.813 97.481 -34.406 68.813 0.000 0
## lmm_model_populus_shannon25 8 22.833 35.501 -3.416 6.833 61.980 0
## lmm_model_populus_shannon26 8 36.846 49.515 -10.423 20.846 0.000 0
## lmm_model_populus_shannon27 8 6.738 19.406 4.631 -9.262 30.109 0
## lmm_model_populus_shannon1 12 89.060 108.062 -32.530 65.060 0.000 4
## lmm_model_populus_shannon2 12 11.743 30.746 6.128 -12.257 77.317 0
## lmm_model_populus_shannon3 12 42.652 61.655 -9.326 18.652 0.000 0
## lmm_model_populus_shannon4 12 211.005 230.007 -93.502 187.005 0.000 0
## lmm_model_populus_shannon5 12 29.901 48.903 -2.951 5.901 181.104 0
## lmm_model_populus_shannon21 12 89.060 108.062 -32.530 65.060 0.000 0
## lmm_model_populus_shannon22 12 42.918 61.920 -9.459 18.918 46.142 0
## lmm_model_populus_shannon23 12 11.864 30.866 6.068 -12.136 31.053 0
## Pr(>Chisq)
## lmm_model_populus_shannon11
## lmm_model_populus_shannon12
## lmm_model_populus_shannon13
## lmm_model_populus_shannon14
## lmm_model_populus_shannon15
## lmm_model_populus_shannon6 1
## lmm_model_populus_shannon7
## lmm_model_populus_shannon8
## lmm_model_populus_shannon9
## lmm_model_populus_shannon10
## lmm_model_populus_shannon16
## lmm_model_populus_shannon17
## lmm_model_populus_shannon18
## lmm_model_populus_shannon19
## lmm_model_populus_shannon20
## lmm_model_populus_shannon24
## lmm_model_populus_shannon25
## lmm_model_populus_shannon26
## lmm_model_populus_shannon27
## lmm_model_populus_shannon1 1
## lmm_model_populus_shannon2
## lmm_model_populus_shannon3
## lmm_model_populus_shannon4
## lmm_model_populus_shannon5
## lmm_model_populus_shannon21
## lmm_model_populus_shannon22
## lmm_model_populus_shannon23
## BEST: b/w `lmm_model_populus_shannon7`, `lmm_model_populus_shannon15`, &
## `lmm_model_populus_shannon20`...
# ANOVA of LMM model using `car` package.
library(car)
anova_lmm_populus_shannon1 <- Anova(lmm_model_populus_shannon1)
anova_lmm_populus_shannon2 <- Anova(lmm_model_populus_shannon2)
anova_lmm_populus_shannon3 <- Anova(lmm_model_populus_shannon3)
anova_lmm_populus_shannon4 <- Anova(lmm_model_populus_shannon4)
anova_lmm_populus_shannon5 <- Anova(lmm_model_populus_shannon5)
anova_lmm_populus_shannon6 <- Anova(lmm_model_populus_shannon6)
anova_lmm_populus_shannon7 <- Anova(lmm_model_populus_shannon7)
anova_lmm_populus_shannon8 <- Anova(lmm_model_populus_shannon8)
anova_lmm_populus_shannon9 <- Anova(lmm_model_populus_shannon9)
anova_lmm_populus_shannon10 <- Anova(lmm_model_populus_shannon10)
anova_lmm_populus_shannon11 <- Anova(lmm_model_populus_shannon11)
anova_lmm_populus_shannon12 <- Anova(lmm_model_populus_shannon12)
anova_lmm_populus_shannon13 <- Anova(lmm_model_populus_shannon13)
anova_lmm_populus_shannon14 <- Anova(lmm_model_populus_shannon14)
anova_lmm_populus_shannon15 <- Anova(lmm_model_populus_shannon15)
anova_lmm_populus_shannon16 <- Anova(lmm_model_populus_shannon16)
anova_lmm_populus_shannon17 <- Anova(lmm_model_populus_shannon17)
anova_lmm_populus_shannon18 <- Anova(lmm_model_populus_shannon18)
anova_lmm_populus_shannon19 <- Anova(lmm_model_populus_shannon19)
anova_lmm_populus_shannon20 <- Anova(lmm_model_populus_shannon20)
summary(anova_lmm_populus_shannon1)
## Chisq Df Pr(>Chisq)
## Min. :0.002773 Min. :1.0 Min. :0.2913
## 1st Qu.:1.521637 1st Qu.:2.5 1st Qu.:0.4212
## Median :3.040502 Median :4.0 Median :0.5511
## Mean :2.668214 Mean :3.0 Mean :0.6001
## 3rd Qu.:4.000934 3rd Qu.:4.0 3rd Qu.:0.7545
## Max. :4.961366 Max. :4.0 Max. :0.9580
summary(anova_lmm_populus_shannon2)
## Chisq Df Pr(>Chisq)
## Min. :0.003942 Min. :1.0 Min. :0.2643
## 1st Qu.:1.191573 1st Qu.:2.5 1st Qu.:0.4654
## Median :2.379204 Median :4.0 Median :0.6664
## Mean :2.538251 Mean :3.0 Mean :0.6269
## 3rd Qu.:3.805406 3rd Qu.:4.0 3rd Qu.:0.8082
## Max. :5.231608 Max. :4.0 Max. :0.9499
summary(anova_lmm_populus_shannon3)
## Chisq Df Pr(>Chisq)
## Min. :0.007289 Min. :1.0 Min. :0.2698
## 1st Qu.:0.806786 1st Qu.:2.5 1st Qu.:0.5388
## Median :1.606282 Median :4.0 Median :0.8077
## Mean :2.262752 Mean :3.0 Mean :0.6698
## 3rd Qu.:3.390483 3rd Qu.:4.0 3rd Qu.:0.8698
## Max. :5.174685 Max. :4.0 Max. :0.9320
summary(anova_lmm_populus_shannon4)
## Chisq Df Pr(>Chisq)
## Min. :0.000794 Min. :1.0 Min. :0.3832
## 1st Qu.:1.827252 1st Qu.:2.5 1st Qu.:0.4191
## Median :3.653710 Median :4.0 Median :0.4549
## Mean :2.608834 Mean :3.0 Mean :0.6052
## 3rd Qu.:3.912854 3rd Qu.:4.0 3rd Qu.:0.7162
## Max. :4.171997 Max. :4.0 Max. :0.9775
summary(anova_lmm_populus_shannon5)
## Chisq Df Pr(>Chisq)
## Min. :0.01824 Min. :1.0 Min. :0.3464
## 1st Qu.:0.30678 1st Qu.:2.5 1st Qu.:0.6195
## Median :0.59533 Median :4.0 Median :0.8926
## Mean :1.69366 Mean :3.0 Mean :0.7342
## 3rd Qu.:2.53137 3rd Qu.:4.0 3rd Qu.:0.9281
## Max. :4.46741 Max. :4.0 Max. :0.9636
summary(anova_lmm_populus_shannon6)
## Chisq Df Pr(>Chisq)
## Min. :0.004466 Min. :1.00 Min. :0.08535
## 1st Qu.:2.047300 1st Qu.:1.75 1st Qu.:0.30069
## Median :4.090135 Median :2.50 Median :0.51603
## Mean :4.090135 Mean :2.50 Mean :0.51603
## 3rd Qu.:6.132969 3rd Qu.:3.25 3rd Qu.:0.73138
## Max. :8.175804 Max. :4.00 Max. :0.94672
summary(anova_lmm_populus_shannon7)
## Chisq Df Pr(>Chisq)
## Min. :0.005093 Min. :1.00 Min. :0.08354
## 1st Qu.:2.061103 1st Qu.:1.75 1st Qu.:0.29843
## Median :4.117113 Median :2.50 Median :0.51332
## Mean :4.117113 Mean :2.50 Mean :0.51332
## 3rd Qu.:6.173122 3rd Qu.:3.25 3rd Qu.:0.72822
## Max. :8.229132 Max. :4.00 Max. :0.94311
summary(anova_lmm_populus_shannon8)
## Chisq Df Pr(>Chisq)
## Min. :0.008419 Min. :1.00 Min. :0.1049
## 1st Qu.:1.920899 1st Qu.:1.75 1st Qu.:0.3104
## Median :3.833380 Median :2.50 Median :0.5159
## Mean :3.833380 Mean :2.50 Mean :0.5159
## 3rd Qu.:5.745860 3rd Qu.:3.25 3rd Qu.:0.7214
## Max. :7.658340 Max. :4.00 Max. :0.9269
summary(anova_lmm_populus_shannon9)
## Chisq Df Pr(>Chisq)
## Min. :0.004415 Min. :1.00 Min. :0.1298
## 1st Qu.:1.782824 1st Qu.:1.75 1st Qu.:0.3341
## Median :3.561234 Median :2.50 Median :0.5384
## Mean :3.561234 Mean :2.50 Mean :0.5384
## 3rd Qu.:5.339643 3rd Qu.:3.25 3rd Qu.:0.7427
## Max. :7.118053 Max. :4.00 Max. :0.9470
summary(anova_lmm_populus_shannon10)
## Chisq Df Pr(>Chisq)
## Min. :0.02014 Min. :1.00 Min. :0.2114
## 1st Qu.:1.47531 1st Qu.:1.75 1st Qu.:0.3803
## Median :2.93047 Median :2.50 Median :0.5492
## Mean :2.93047 Mean :2.50 Mean :0.5492
## 3rd Qu.:4.38564 3rd Qu.:3.25 3rd Qu.:0.7182
## Max. :5.84080 Max. :4.00 Max. :0.8871
summary(anova_lmm_populus_shannon11)
## Chisq Df Pr(>Chisq)
## Min. :0.01989 Min. :1 Min. :0.8878
## 1st Qu.:0.01989 1st Qu.:1 1st Qu.:0.8878
## Median :0.01989 Median :1 Median :0.8878
## Mean :0.01989 Mean :1 Mean :0.8878
## 3rd Qu.:0.01989 3rd Qu.:1 3rd Qu.:0.8878
## Max. :0.01989 Max. :1 Max. :0.8878
summary(anova_lmm_populus_shannon12)
## Chisq Df Pr(>Chisq)
## Min. :0.04646 Min. :1 Min. :0.8293
## 1st Qu.:0.04646 1st Qu.:1 1st Qu.:0.8293
## Median :0.04646 Median :1 Median :0.8293
## Mean :0.04646 Mean :1 Mean :0.8293
## 3rd Qu.:0.04646 3rd Qu.:1 3rd Qu.:0.8293
## Max. :0.04646 Max. :1 Max. :0.8293
summary(anova_lmm_populus_shannon13)
## Chisq Df Pr(>Chisq)
## Min. :0.06158 Min. :1 Min. :0.804
## 1st Qu.:0.06158 1st Qu.:1 1st Qu.:0.804
## Median :0.06158 Median :1 Median :0.804
## Mean :0.06158 Mean :1 Mean :0.804
## 3rd Qu.:0.06158 3rd Qu.:1 3rd Qu.:0.804
## Max. :0.06158 Max. :1 Max. :0.804
summary(anova_lmm_populus_shannon14)
## Chisq Df Pr(>Chisq)
## Min. :0.004151 Min. :1 Min. :0.9486
## 1st Qu.:0.004151 1st Qu.:1 1st Qu.:0.9486
## Median :0.004151 Median :1 Median :0.9486
## Mean :0.004151 Mean :1 Mean :0.9486
## 3rd Qu.:0.004151 3rd Qu.:1 3rd Qu.:0.9486
## Max. :0.004151 Max. :1 Max. :0.9486
summary(anova_lmm_populus_shannon15)
## Chisq Df Pr(>Chisq)
## Min. :0.03302 Min. :1 Min. :0.8558
## 1st Qu.:0.03302 1st Qu.:1 1st Qu.:0.8558
## Median :0.03302 Median :1 Median :0.8558
## Mean :0.03302 Mean :1 Mean :0.8558
## 3rd Qu.:0.03302 3rd Qu.:1 3rd Qu.:0.8558
## Max. :0.03302 Max. :1 Max. :0.8558
summary(anova_lmm_populus_shannon16)
## Chisq Df Pr(>Chisq)
## Min. :0.0236 Min. :1.00 Min. :0.1075
## 1st Qu.:1.9170 1st Qu.:1.75 1st Qu.:0.3001
## Median :3.8104 Median :2.50 Median :0.4927
## Mean :3.8104 Mean :2.50 Mean :0.4927
## 3rd Qu.:5.7039 3rd Qu.:3.25 3rd Qu.:0.6853
## Max. :7.5973 Max. :4.00 Max. :0.8779
summary(anova_lmm_populus_shannon17)
## Chisq Df Pr(>Chisq)
## Min. :0.05149 Min. :1.00 Min. :0.1511
## 1st Qu.:1.71994 1st Qu.:1.75 1st Qu.:0.3185
## Median :3.38840 Median :2.50 Median :0.4858
## Mean :3.38840 Mean :2.50 Mean :0.4858
## 3rd Qu.:5.05685 3rd Qu.:3.25 3rd Qu.:0.6532
## Max. :6.72531 Max. :4.00 Max. :0.8205
summary(anova_lmm_populus_shannon18)
## Chisq Df Pr(>Chisq)
## Min. :0.06393 Min. :1.00 Min. :0.2716
## 1st Qu.:1.33715 1st Qu.:1.75 1st Qu.:0.4038
## Median :2.61036 Median :2.50 Median :0.5360
## Mean :2.61036 Mean :2.50 Mean :0.5360
## 3rd Qu.:3.88358 3rd Qu.:3.25 3rd Qu.:0.6682
## Max. :5.15680 Max. :4.00 Max. :0.8004
summary(anova_lmm_populus_shannon19)
## Chisq Df Pr(>Chisq)
## Min. :0.004935 Min. :1.00 Min. :0.1317
## 1st Qu.:1.773715 1st Qu.:1.75 1st Qu.:0.3348
## Median :3.542495 Median :2.50 Median :0.5379
## Mean :3.542495 Mean :2.50 Mean :0.5379
## 3rd Qu.:5.311275 3rd Qu.:3.25 3rd Qu.:0.7409
## Max. :7.080055 Max. :4.00 Max. :0.9440
summary(anova_lmm_populus_shannon20)
## Chisq Df Pr(>Chisq)
## Min. :0.03806 Min. :1.00 Min. :0.1171
## 1st Qu.:1.87338 1st Qu.:1.75 1st Qu.:0.2992
## Median :3.70871 Median :2.50 Median :0.4812
## Mean :3.70871 Mean :2.50 Mean :0.4812
## 3rd Qu.:5.54403 3rd Qu.:3.25 3rd Qu.:0.6633
## Max. :7.37936 Max. :4.00 Max. :0.8453
## Hard to choose based on this, but best seems to be
## `lmm_model_populus_shannon7`...
## NOTE: `lmm_model_populus_shannon7` also has NO singularity issues &
## relatively similar diagnostics to `lmm_model_populus_shannon15` &
## `lmm_model_populus_shannon20` (and `lmm_model_populus_shannon20` does have
## singularity issue).
## Followed closely by: `lmm_model_populus_shannon6`,
## `lmm_model_populus_shannon8`, `lmm_model_populus_shannon16`, &
## `lmm_model_populus_shannon20`
################################################################################ CHOICE:
################################################################################ `lmm_model_populus_shannon15`
################################################################################ (AIC
################################################################################ and
################################################################################ BIC
################################################################################ blow
################################################################################ the
################################################################################ others
################################################################################ out,
################################################################################ on
################################################################################ top
################################################################################ of
################################################################################ everything
################################################################################ else)
lmm_model_populus_shannon15 <- lmer(sqrt(alphaDiv) ~ GDD_5C + (1 | Plant_ID), data = subset(asv_scaled_noPlants_Phen_filt_LMM,
Species == "Populus_tremuloides"))
summary(lmm_model_populus_shannon15)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: sqrt(alphaDiv) ~ GDD_5C + (1 | Plant_ID)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides")
##
## REML criterion at convergence: 18.6
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -4.6496 -0.1290 0.1144 0.5618 1.1004
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0.002058 0.04537
## Residual 0.054310 0.23305
## Number of obs: 36, groups: Plant_ID, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 1.841e+00 9.329e-02 3.075e+01 19.739 <2e-16 ***
## GDD_5C -1.046e-05 5.754e-05 3.005e+01 -0.182 0.857
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## GDD_5C -0.883
library(rsq)
rsq.lmm(lmm_model_populus_shannon15)
## $model
## [1] 0.03521204
##
## $fixed
## [1] 0.001009757
##
## $random
## [1] 0.03420228
################################################################################ BUT
################################################################################ IF
################################################################################ SINGULARITIES
################################################################################ ALLOWED:
################################################################################ Maybe...
################################################################################ `lmm_model_populus_shannon20`
# lmm_model_populus_shannon20 <- lmer(sqrt(alphaDiv) ~ GDD_5C + GDD_5C:Plant_ID
# + (1 | Plant_ID), data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species ==
# 'Populus_tremuloides'))
# summary(lmm_model_populus_shannon20)
## NOTE: This is why we likely DON'T choose the one with SINGULARITY... Notice
## that here, the R^2 for the Random Effect is 0, so NO VARIANCE in our Random
## Effect (corroborated by our ChiSq values and >Pr(ChiSq) being oddly all
## similar, and our R2c and R2m being the same too...):
# library(rsq)
# rsq.lmm(lmm_model_populus_shannon20)
# $model [1] 0.1982342
# $fixed [1] 0.1982342
# $random -> NOTE NO VARIANCE! [1] 0
#--------------------------------------------------------------
## Conditional & Marginal R^2 for Model
#--------------------------------------------------------------
# Calculate marginal R-squared for `GDD_5C`
populus_shannon_r_squared <- r.squaredGLMM(lmm_model_populus_shannon15, mu0 = "fixed")
print(populus_shannon_r_squared)
## R2m R2c
## [1,] 0.0009082405 0.03739107
# install.packages('urca')
library(urca)
# Perform KPSS test
kpss_populus_alphaDiv <- ur.kpss(populus_data$alphaDiv)
kpss_populus_alphaDiv <- ur.kpss(asv_scaled_noPlants_Phen_filt_LMM$alphaDiv[asv_scaled_noPlants_Phen_filt_LMM$Species ==
"Populus_tremuloides"])
# summary of KPSS Test
summary(kpss_populus_alphaDiv)
##
## #######################
## # KPSS Unit Root Test #
## #######################
##
## Test is of type: mu with 3 lags.
##
## Value of test-statistic is: 0.2842
##
## Critical value for a significance level of:
## 10pct 5pct 2.5pct 1pct
## critical values 0.347 0.463 0.574 0.739
# Shannon diversity in Populus is STATIONARY!
# Subset a dataset for each Species
betula_data <- subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia")
populus_data <- subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides")
# Subset data by GDD
alpha_437_bet <- subset(betula_data, GDD_5C == 437)
alpha_605_bet <- subset(betula_data, GDD_5C == 605)
alpha_1087_bet <- subset(betula_data, GDD_5C == 1087)
alpha_1606_bet <- subset(betula_data, GDD_5C == 1606)
alpha_1992_bet <- subset(betula_data, GDD_5C == 1992)
alpha_2140_bet <- subset(betula_data, GDD_5C == 2140)
alpha_2219_bet <- subset(betula_data, GDD_5C == 2219)
#(a) GDD 437
shapiro.test(alpha_437_bet$specnumber)
##
## Shapiro-Wilk normality test
##
## data: alpha_437_bet$specnumber
## W = 0.90731, p-value = 0.4516
# p = 0.4405 > 0.05 --> it is NORMAL, so do ANOVA
# Perform ANOVA
anova_specnumber_437_bet <- aov(specnumber ~ plant.id, data = alpha_437_bet)
# Summarize the ANOVA results
summary(anova_specnumber_437_bet)
## Df Sum Sq Mean Sq F value Pr(>F)
## plant.id 1 23.9 23.9 0.043 0.848
## Residuals 3 1654.9 551.6
# Check Normality of Residuals & other diagnostic stats (Levene Test, Q-Q
# plots, Residuals vs. Fitted)?
# Normality of Residuals:
shapiro.test(residuals(anova_specnumber_437_bet)) #p=0.5608>0.05 --> Normality good!
##
## Shapiro-Wilk normality test
##
## data: residuals(anova_specnumber_437_bet)
## W = 0.93075, p-value = 0.6015
# Levene's Test? Q-Q? Residuals vs Fitted?
THEREFORE: There is NO significant difference in the ASV richness between Betula Plant_IDs (indivual plants) at GDD 437 (p=0.886)!
#(b) GDD 605
shapiro.test(alpha_605_bet$specnumber)
##
## Shapiro-Wilk normality test
##
## data: alpha_605_bet$specnumber
## W = 0.95892, p-value = 0.8004
# p = 0.8004 > 0.05 --> it is NORMAL, so do ANOVA
# Perform ANOVA
anova_specnumber_605_bet <- aov(specnumber ~ plant.id, data = alpha_605_bet)
# Summarize the ANOVA results
summary(anova_specnumber_605_bet)
## Df Sum Sq Mean Sq F value Pr(>F)
## plant.id 1 42.4 42.37 0.32 0.611
## Residuals 3 397.6 132.54
# Check Normality of Residuals & other diagnostic stats (Levene Test, Q-Q
# plots, Residuals vs. Fitted)?
# Normality of Residuals:
shapiro.test(residuals(anova_specnumber_605_bet)) #p=0.747>0.05 --> Normality good!
##
## Shapiro-Wilk normality test
##
## data: residuals(anova_specnumber_605_bet)
## W = 0.95138, p-value = 0.747
# Levene's Test? Q-Q? Residuals vs Fitted?
THEREFORE: There is NO significant difference between the plant individuals within Betula at GDD 605 (p=0.611)!
#(c) GDD 1087
shapiro.test(alpha_1087_bet$specnumber)
##
## Shapiro-Wilk normality test
##
## data: alpha_1087_bet$specnumber
## W = 0.67452, p-value = 0.005086
# p = 0.005259 < 0.05 --> it is NOT NORMAL, so do non-parametric Kruskal-Wallis
kruskal.test(alpha_1087_bet$specnumber ~ alpha_1087_bet$plant.id)
##
## Kruskal-Wallis rank sum test
##
## data: alpha_1087_bet$specnumber by alpha_1087_bet$plant.id
## Kruskal-Wallis chi-squared = 4, df = 4, p-value = 0.406
# NOTE: No need to test normality of model, b/c Kruskal-Wallis is specifically
# for non-normality and assumes such.
# Levene Test? Q-Q Plots? Residuals vs. Fitted
THEREFORE: There is NO significant difference in ASV richness between plant individuals within Betula at GDD 1087 (p=0.406)!
#(d) GDD 1606
shapiro.test(alpha_1606_bet$specnumber)
##
## Shapiro-Wilk normality test
##
## data: alpha_1606_bet$specnumber
## W = 0.90528, p-value = 0.4397
# p = 0.4254 > 0.05 --> it is NORMAL, so do ANOVA
# Perform ANOVA
anova_specnumber_1606_bet <- aov(specnumber ~ plant.id, data = alpha_1606_bet)
# Summarize the ANOVA results
summary(anova_specnumber_1606_bet)
## Df Sum Sq Mean Sq F value Pr(>F)
## plant.id 1 2154 2154 1.853 0.267
## Residuals 3 3487 1162
# Check Normality of Residuals & other diagnostic stats (Levene Test, Q-Q
# plots, Residuals vs. Fitted)?
# Normality of Residuals:
shapiro.test(residuals(anova_specnumber_1606_bet)) #p=0.9824>0.05 --> Normality good!
##
## Shapiro-Wilk normality test
##
## data: residuals(anova_specnumber_1606_bet)
## W = 0.99151, p-value = 0.9847
# Levene's Test? Q-Q? Residuals vs Fitted?
THEREFORE: There is NO significant difference in ASV richness between plant individuals within Betula at GDD 1606 (p=0.267)!
#(e) GDD 1992
shapiro.test(alpha_1992_bet$specnumber)
##
## Shapiro-Wilk normality test
##
## data: alpha_1992_bet$specnumber
## W = 0.80028, p-value = 0.08146
# p = 0.08171 > 0.05 --> it is NORMAL, so do ANOVA!
# Perform ANOVA
anova_specnumber_1992_bet <- aov(specnumber ~ plant.id, data = alpha_1992_bet)
# Summarize the ANOVA results
summary(anova_specnumber_1992_bet)
## Df Sum Sq Mean Sq F value Pr(>F)
## plant.id 1 395 395.5 0.194 0.69
## Residuals 3 6129 2042.8
# Check Normality of Residuals & other diagnostic stats (Levene Test, Q-Q
# plots, Residuals vs. Fitted)?
# Normality of Residuals:
shapiro.test(residuals(anova_specnumber_1992_bet)) #p=0.05241>0.05 --> Normality good!
##
## Shapiro-Wilk normality test
##
## data: residuals(anova_specnumber_1992_bet)
## W = 0.78223, p-value = 0.0576
# Levene's Test? Q-Q? Residuals vs Fitted?
THEREFORE: There is NO significant difference in ASV richness between plant individuals within Betula at GDD 1992 (p=0.3472)!
#(f) GDD 2140
shapiro.test(alpha_2140_bet$specnumber)
##
## Shapiro-Wilk normality test
##
## data: alpha_2140_bet$specnumber
## W = 0.90276, p-value = 0.4253
# p = 0.3872 > 0.05 --> it is NORMAL, so do ANOVA
# Perform ANOVA
anova_specnumber_2140_bet <- aov(specnumber ~ plant.id, data = alpha_2140_bet)
# Summarize the ANOVA results
summary(anova_specnumber_2140_bet)
## Df Sum Sq Mean Sq F value Pr(>F)
## plant.id 1 121 121.2 0.055 0.83
## Residuals 3 6626 2208.7
# Check Normality of Residuals & other diagnostic stats (Levene Test, Q-Q
# plots, Residuals vs. Fitted)?
# Normality of Residuals:
shapiro.test(residuals(anova_specnumber_2140_bet)) #p=0.485>0.05 --> Normality good!
##
## Shapiro-Wilk normality test
##
## data: residuals(anova_specnumber_2140_bet)
## W = 0.91773, p-value = 0.5154
# Levene's Test? Q-Q? Residuals vs Fitted?
THEREFORE: There is NO significant difference in ASV richness between plant individuals within Betula at GDD 2140 (p=0.819)!
#(g) GDD 2219
shapiro.test(alpha_2219_bet$specnumber)
##
## Shapiro-Wilk normality test
##
## data: alpha_2219_bet$specnumber
## W = 0.95513, p-value = 0.7737
# p = 0.7966 > 0.05 --> it is NORMAL, so do ANOVA
# Perform ANOVA
anova_specnumber_2219_bet <- aov(specnumber ~ plant.id, data = alpha_2219_bet)
# Summarize the ANOVA results
summary(anova_specnumber_2219_bet)
## Df Sum Sq Mean Sq F value Pr(>F)
## plant.id 1 0.4 0.4 0.001 0.981
## Residuals 3 1740.8 580.3
# Check Normality of Residuals & other diagnostic stats (Levene Test, Q-Q
# plots, Residuals vs. Fitted)?
# Normality of Residuals:
shapiro.test(residuals(anova_specnumber_2219_bet)) #p=0.8123>0.05 --> Normality good!
##
## Shapiro-Wilk normality test
##
## data: residuals(anova_specnumber_2219_bet)
## W = 0.9571, p-value = 0.7876
# Levene's Test? Q-Q? Residuals vs Fitted?
THEREFORE: There is NO significant difference in ASV richness between plant individuals within Betula at GDD 2219 (p=0.979)!
#(a) GDD 437
shapiro.test(alpha_437_bet$alphaDiv)
##
## Shapiro-Wilk normality test
##
## data: alpha_437_bet$alphaDiv
## W = 0.87474, p-value = 0.2862
# p = 0.3052 > 0.05 --> it is NORMAL, so do ANOVA
# Perform ANOVA
anova_shannon_437_bet <- aov(alphaDiv ~ plant.id, data = alpha_437_bet)
# Summarize the ANOVA results
summary(anova_shannon_437_bet)
## Df Sum Sq Mean Sq F value Pr(>F)
## plant.id 1 0.1032 0.1032 0.199 0.686
## Residuals 3 1.5567 0.5189
# Formal Test of Normality of Residuals
shapiro.test(residuals(anova_shannon_437_bet))
##
## Shapiro-Wilk normality test
##
## data: residuals(anova_shannon_437_bet)
## W = 0.69988, p-value = 0.009549
# p=0.008123 < 0.05 -> NOT normal residuals = do Kruskal-Wallis
kruskal.test(alpha_437_bet$alphaDiv ~ alpha_437_bet$plant.id)
##
## Kruskal-Wallis rank sum test
##
## data: alpha_437_bet$alphaDiv by alpha_437_bet$plant.id
## Kruskal-Wallis chi-squared = 4, df = 4, p-value = 0.406
THEREFORE: There IS a significant difference in Shannon diversity between plant individuals within Betula at GDD 437, solely based on individual plant characteristics (p=0.406)!
#(b) GDD 605
shapiro.test(alpha_605_bet$alphaDiv)
##
## Shapiro-Wilk normality test
##
## data: alpha_605_bet$alphaDiv
## W = 0.98624, p-value = 0.965
# p = 0.965 > 0.05 --> it is NORMAL, so do ANOVA
# Perform ANOVA
anova_shannon_605_bet <- aov(alphaDiv ~ plant.id, data = alpha_605_bet)
# Summarize the ANOVA results
summary(anova_shannon_605_bet)
## Df Sum Sq Mean Sq F value Pr(>F)
## plant.id 1 0.5098 0.5098 6.09 0.0902 .
## Residuals 3 0.2511 0.0837
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Normality of Residuals:
shapiro.test(residuals(anova_shannon_605_bet)) #p=0.1136 > 0.05 --> it's Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(anova_shannon_605_bet)
## W = 0.81844, p-value = 0.1136
# Levene Test? Q-Q Plots? Residuals vs. Fitted
THEREFORE: There IS significant difference in Shannon diversity between plant individuals (based solely on Plant_ID characteristics) within Betula at GDD 605 (p=0.0902)!
#(c) GDD 1087
shapiro.test(alpha_1087_bet$alphaDiv)
##
## Shapiro-Wilk normality test
##
## data: alpha_1087_bet$alphaDiv
## W = 0.96978, p-value = 0.8739
# p = 0.8724 > 0.05 --> it is NORMAL, so do ANOVA
# Perform ANOVA
anova_shannon_1087_bet <- aov(alphaDiv ~ plant.id, data = alpha_1087_bet)
# Summarize the ANOVA results
summary(anova_shannon_1087_bet)
## Df Sum Sq Mean Sq F value Pr(>F)
## plant.id 1 0.8771 0.8771 2.268 0.229
## Residuals 3 1.1604 0.3868
# Normality of Residuals:
shapiro.test(residuals(anova_shannon_1087_bet)) #p=0.9662 > 0.05 --> it's Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(anova_shannon_1087_bet)
## W = 0.9871, p-value = 0.9686
# Levene Test? Q-Q Plots? Residuals vs. Fitted
THEREFORE: There is NO significant difference in Shannon diversity between the two host species at GDD 1087 (p=0.101)!
#(d) GDD 1606
shapiro.test(alpha_1606_bet$alphaDiv)
##
## Shapiro-Wilk normality test
##
## data: alpha_1606_bet$alphaDiv
## W = 0.95375, p-value = 0.7639
# p = 0.7659 > 0.05 --> it is NORMAL, so do ANOVA
# Perform ANOVA
anova_shannon_1606_bet <- aov(alphaDiv ~ plant.id, data = alpha_1606_bet)
# Summarize the ANOVA results
summary(anova_shannon_1606_bet)
## Df Sum Sq Mean Sq F value Pr(>F)
## plant.id 1 0.3837 0.3837 0.493 0.533
## Residuals 3 2.3358 0.7786
# Normality of Residuals:
shapiro.test(residuals(anova_shannon_1606_bet)) #p=0.0672 > 0.05 --> it's Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(anova_shannon_1606_bet)
## W = 0.78149, p-value = 0.05676
# Levene Test? Q-Q Plots? Residuals vs. Fitted
THEREFORE: There is NO significant difference in Shannon diversity between plant individual (based solely on plant characteristics) within Betula at GDD 1606 (p=0.526)!
#(e) GDD 1992
shapiro.test(alpha_1992_bet$alphaDiv)
##
## Shapiro-Wilk normality test
##
## data: alpha_1992_bet$alphaDiv
## W = 0.92773, p-value = 0.581
# p = 0.5636 > 0.05 --> it is NORMAL, so do ANOVA
# Perform ANOVA
anova_shannon_1992_bet <- aov(alphaDiv ~ plant.id, data = alpha_1992_bet)
# Summarize the ANOVA results
summary(anova_shannon_1992_bet)
## Df Sum Sq Mean Sq F value Pr(>F)
## plant.id 1 0.7761 0.7761 3.365 0.164
## Residuals 3 0.6918 0.2306
# Normality of Residuals:
shapiro.test(residuals(anova_shannon_1992_bet)) #p=0.4876 > 0.05 --> it's Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(anova_shannon_1992_bet)
## W = 0.90985, p-value = 0.4667
# Levene Test? Q-Q Plots? Residuals vs. Fitted
THEREFORE: There is NO significant difference in Shannon diversity between the two host species at GDD 1992 (p=0.185)!
#(f) GDD 2140
shapiro.test(alpha_2140_bet$alphaDiv)
##
## Shapiro-Wilk normality test
##
## data: alpha_2140_bet$alphaDiv
## W = 0.87385, p-value = 0.2824
# p = 0.3255 > 0.05 --> it is NORMAL, so do ANOVA
# Perform ANOVA
anova_shannon_2140_bet <- aov(alphaDiv ~ plant.id, data = alpha_2140_bet)
# Summarize the ANOVA results
summary(anova_shannon_2140_bet)
## Df Sum Sq Mean Sq F value Pr(>F)
## plant.id 1 0.0373 0.0373 0.051 0.835
## Residuals 3 2.1772 0.7257
# Normality of Residuals:
shapiro.test(residuals(anova_shannon_2140_bet)) #p=0.224 > 0.05 --> it's Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(anova_shannon_2140_bet)
## W = 0.84435, p-value = 0.1773
# Levene Test? Q-Q Plots? Residuals vs. Fitted
THEREFORE: There is NO significant difference in Shannon diversity between plant individuals (solely based on indiv. plant chars) within Betula at GDD 2140 (p=0.842)!
#(g) GDD 2219
shapiro.test(alpha_2219_bet$alphaDiv)
##
## Shapiro-Wilk normality test
##
## data: alpha_2219_bet$alphaDiv
## W = 0.94427, p-value = 0.6963
# p = 0.6994 > 0.05 --> it is NORMAL, so do ANOVA
# Perform ANOVA
anova_shannon_2219_bet <- aov(alphaDiv ~ plant.id, data = alpha_2219_bet)
# Summarize the ANOVA results
summary(anova_shannon_2219_bet)
## Df Sum Sq Mean Sq F value Pr(>F)
## plant.id 1 0.0003 0.0003 0.001 0.981
## Residuals 3 1.3596 0.4532
# Normality of Residuals:
shapiro.test(residuals(anova_shannon_2219_bet)) #p=0.7138 > 0.05 --> it's Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(anova_shannon_2219_bet)
## W = 0.94625, p-value = 0.7104
# Levene Test? Q-Q Plots? Residuals vs. Fitted
THEREFORE: There is NO significant difference in Shannon diversity between plant individuals (solely based on indiv. plant chars) within Betula at GDD 2219 (p=0.981)!
# Subset data by GDD
alpha_437_pop <- subset(populus_data, GDD_5C == 437)
alpha_605_pop <- subset(populus_data, GDD_5C == 605)
alpha_1087_pop <- subset(populus_data, GDD_5C == 1087)
alpha_1606_pop <- subset(populus_data, GDD_5C == 1606)
alpha_1992_pop <- subset(populus_data, GDD_5C == 1992)
alpha_2140_pop <- subset(populus_data, GDD_5C == 2140)
alpha_2219_pop <- subset(populus_data, GDD_5C == 2219)
#(a) GDD 437
shapiro.test(alpha_437_pop$specnumber)
##
## Shapiro-Wilk normality test
##
## data: alpha_437_pop$specnumber
## W = 0.85511, p-value = 0.2112
# p = 0.2112 > 0.05 --> it is NORMAL, so do ANOVA
# Perform ANOVA
anova_specnumber_437_pop <- aov(specnumber ~ plant.id, data = alpha_437_pop)
# Summarize the ANOVA results
summary(anova_specnumber_437_pop)
## Df Sum Sq Mean Sq F value Pr(>F)
## plant.id 1 36.26 36.26 0.963 0.399
## Residuals 3 112.94 37.65
# Check Normality of Residuals & other diagnostic stats (Levene Test, Q-Q
# plots, Residuals vs. Fitted)?
# Normality of Residuals:
shapiro.test(residuals(anova_specnumber_437_pop)) #p=0.1386>0.05 --> Normality good!
##
## Shapiro-Wilk normality test
##
## data: residuals(anova_specnumber_437_pop)
## W = 0.82977, p-value = 0.1386
# Levene's Test? Q-Q? Residuals vs Fitted?
THEREFORE: There is NO significant difference in the ASV richness between Populus Plant_IDs (indivual plants, based solely on plant chars) at GDD 437 (p=0.399)!
#(b) GDD 605
shapiro.test(alpha_605_pop$specnumber)
##
## Shapiro-Wilk normality test
##
## data: alpha_605_pop$specnumber
## W = 0.79881, p-value = 0.07925
# p = 0.07925 > 0.05 --> it is NORMAL, so do ANOVA
# Perform ANOVA
anova_specnumber_605_pop <- aov(specnumber ~ plant.id, data = alpha_605_pop)
# Summarize the ANOVA results
summary(anova_specnumber_605_pop)
## Df Sum Sq Mean Sq F value Pr(>F)
## plant.id 1 79.2 79.2 0.241 0.657
## Residuals 3 986.8 328.9
# Check Normality of Residuals & other diagnostic stats (Levene Test, Q-Q
# plots, Residuals vs. Fitted)?
# Normality of Residuals:
shapiro.test(residuals(anova_specnumber_605_pop)) #p=0.2974>0.05 --> Normality good!
##
## Shapiro-Wilk normality test
##
## data: residuals(anova_specnumber_605_pop)
## W = 0.87733, p-value = 0.2974
# Levene's Test? Q-Q? Residuals vs Fitted?
THEREFORE: There is NO significant difference between the plant individuals within Populus (solely basedon plant chars) at GDD 605 (p=0.611)!
#(c) GDD 1087
shapiro.test(alpha_1087_pop$specnumber)
##
## Shapiro-Wilk normality test
##
## data: alpha_1087_pop$specnumber
## W = 0.88518, p-value = 0.2937
# p = 0.2937 < 0.05 --> it is NORMAL, so do ANOVA
# Perform ANOVA
anova_specnumber_1087_pop <- aov(specnumber ~ plant.id, data = alpha_1087_pop)
# Summarize the ANOVA results
summary(anova_specnumber_1087_pop)
## Df Sum Sq Mean Sq F value Pr(>F)
## plant.id 1 1154 1154 1.139 0.346
## Residuals 4 4052 1013
# Check Normality of Residuals & other diagnostic stats (Levene Test, Q-Q
# plots, Residuals vs. Fitted)?
# Normality of Residuals:
shapiro.test(residuals(anova_specnumber_1087_pop)) #p=0.1008>0.05 --> Normality good!
##
## Shapiro-Wilk normality test
##
## data: residuals(anova_specnumber_1087_pop)
## W = 0.87061, p-value = 0.2286
# Levene's Test? Q-Q? Residuals vs Fitted?
THEREFORE: There is NO significant difference in ASV richness between plant individuals within Populus (based solely on plant characteristics) at GDD 1087 (p=0.836)!
#(d) GDD 1606
shapiro.test(alpha_1606_pop$specnumber)
##
## Shapiro-Wilk normality test
##
## data: alpha_1606_pop$specnumber
## W = 0.79583, p-value = 0.07491
# p = 0.07419 > 0.05 --> it is NORMAL, so do ANOVA
# Perform ANOVA
anova_specnumber_1606_pop <- aov(specnumber ~ plant.id, data = alpha_1606_pop)
# Summarize the ANOVA results
summary(anova_specnumber_1606_pop)
## Df Sum Sq Mean Sq F value Pr(>F)
## plant.id 1 40 40.3 0.023 0.888
## Residuals 3 5200 1733.5
# Check Normality of Residuals & other diagnostic stats (Levene Test, Q-Q
# plots, Residuals vs. Fitted)?
# Normality of Residuals:
shapiro.test(residuals(anova_specnumber_1606_pop)) #p=0.03682<0.05 --> Normality NOT good!
##
## Shapiro-Wilk normality test
##
## data: residuals(anova_specnumber_1606_pop)
## W = 0.76011, p-value = 0.03682
# Do non-parametric Kruskal-Wallis!
kruskal.test(alpha_1606_pop$alphaDiv ~ alpha_1606_pop$plant.id)
##
## Kruskal-Wallis rank sum test
##
## data: alpha_1606_pop$alphaDiv by alpha_1606_pop$plant.id
## Kruskal-Wallis chi-squared = 4, df = 4, p-value = 0.406
THEREFORE: There is NO significant difference in ASV richness between plant individuals within Populus (based solely on plant chars) at GDD 1606 (p=0.406)!
#(e) GDD 1992
shapiro.test(alpha_1992_pop$specnumber)
##
## Shapiro-Wilk normality test
##
## data: alpha_1992_pop$specnumber
## W = 0.95799, p-value = 0.7939
# p = 0.7939 > 0.05 --> it is NORMAL, so do ANOVA!
# Perform ANOVA
anova_specnumber_1992_pop <- aov(specnumber ~ plant.id, data = alpha_1992_pop)
# Summarize the ANOVA results
summary(anova_specnumber_1992_pop)
## Df Sum Sq Mean Sq F value Pr(>F)
## plant.id 1 25.4 25.4 0.045 0.846
## Residuals 3 1689.8 563.3
# Check Normality of Residuals & other diagnostic stats (Levene Test, Q-Q
# plots, Residuals vs. Fitted)?
# Normality of Residuals:
shapiro.test(residuals(anova_specnumber_1992_pop)) #p=0.8941>0.05 --> Normality good!
##
## Shapiro-Wilk normality test
##
## data: residuals(anova_specnumber_1992_pop)
## W = 0.97299, p-value = 0.8941
# Levene's Test? Q-Q? Residuals vs Fitted?
THEREFORE: There is NO significant difference in ASV richness between plant individuals within Populus (solely based on individual plant chars) at GDD 1992 (p=0.846)!
#(f) GDD 2140
shapiro.test(alpha_2140_pop$specnumber)
##
## Shapiro-Wilk normality test
##
## data: alpha_2140_pop$specnumber
## W = 0.94435, p-value = 0.6968
# p = 0.6968 > 0.05 --> it is NORMAL, so do ANOVA
# Perform ANOVA
anova_specnumber_2140_pop <- aov(specnumber ~ plant.id, data = alpha_2140_pop)
# Summarize the ANOVA results
summary(anova_specnumber_2140_pop)
## Df Sum Sq Mean Sq F value Pr(>F)
## plant.id 1 539 539.0 1.492 0.309
## Residuals 3 1084 361.3
# Check Normality of Residuals & other diagnostic stats (Levene Test, Q-Q
# plots, Residuals vs. Fitted)?
# Normality of Residuals:
shapiro.test(residuals(anova_specnumber_2140_pop)) #p=0.5685>0.05 --> Normality good!
##
## Shapiro-Wilk normality test
##
## data: residuals(anova_specnumber_2140_pop)
## W = 0.92587, p-value = 0.5685
# Levene's Test? Q-Q? Residuals vs Fitted?
THEREFORE: There is NO significant difference in ASV richness between plant individuals within Populus (based only on indiv. plant chars) at GDD 2140 (p=0.309)!
#(g) GDD 2219
shapiro.test(alpha_2219_pop$specnumber)
##
## Shapiro-Wilk normality test
##
## data: alpha_2219_pop$specnumber
## W = 0.89395, p-value = 0.3774
# p = 0.3774 > 0.05 --> it is NORMAL, so do ANOVA
# Perform ANOVA
anova_specnumber_2219_pop <- aov(specnumber ~ plant.id, data = alpha_2219_pop)
# Summarize the ANOVA results
summary(anova_specnumber_2219_pop)
## Df Sum Sq Mean Sq F value Pr(>F)
## plant.id 1 90 89.9 0.07 0.809
## Residuals 3 3855 1285.1
# Check Normality of Residuals & other diagnostic stats (Levene Test, Q-Q
# plots, Residuals vs. Fitted)?
# Normality of Residuals:
shapiro.test(residuals(anova_specnumber_2219_pop)) #p=0.158>0.05 --> Normality good!
##
## Shapiro-Wilk normality test
##
## data: residuals(anova_specnumber_2219_pop)
## W = 0.83746, p-value = 0.158
# Levene's Test? Q-Q? Residuals vs Fitted?
THEREFORE: There is NO significant difference in ASV richness between plant individuals within Popullus (based solely on indiv. plant chars) at GDD 2219 (p=0.809)!
#(a) GDD 437
shapiro.test(alpha_437_pop$alphaDiv)
##
## Shapiro-Wilk normality test
##
## data: alpha_437_pop$alphaDiv
## W = 0.95992, p-value = 0.8074
# p = 0.8074 > 0.05 --> it is NORMAL, so do ANOVA
# Perform ANOVA
anova_shannon_437_pop <- aov(alphaDiv ~ plant.id, data = alpha_437_pop)
# Summarize the ANOVA results
summary(anova_shannon_437_pop)
## Df Sum Sq Mean Sq F value Pr(>F)
## plant.id 1 0.00221 0.00221 0.058 0.825
## Residuals 3 0.11354 0.03785
# Formal Test of Normality of Residuals
shapiro.test(residuals(anova_shannon_437_pop))
##
## Shapiro-Wilk normality test
##
## data: residuals(anova_shannon_437_pop)
## W = 0.97543, p-value = 0.9088
# p=0.9088 > 0.05 -> Normality good!
THEREFORE: There IS a significant difference in Shannon diversity between plant individuals within Populus at GDD 437, solely based on individual plant characteristics (p=0.825)!
#(b) GDD 605
shapiro.test(alpha_605_pop$alphaDiv)
##
## Shapiro-Wilk normality test
##
## data: alpha_605_pop$alphaDiv
## W = 0.87488, p-value = 0.2867
# p = 0.2867 > 0.05 --> it is NORMAL, so do ANOVA
# Perform ANOVA
anova_shannon_605_pop <- aov(alphaDiv ~ plant.id, data = alpha_605_pop)
# Summarize the ANOVA results
summary(anova_shannon_605_pop)
## Df Sum Sq Mean Sq F value Pr(>F)
## plant.id 1 0.0337 0.0337 0.134 0.739
## Residuals 3 0.7546 0.2515
# Normality of Residuals:
shapiro.test(residuals(anova_shannon_605_pop)) #p=0.4884 > 0.05 --> it's Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(anova_shannon_605_pop)
## W = 0.91343, p-value = 0.4884
# Levene Test? Q-Q Plots? Residuals vs. Fitted
THEREFORE: There IS significant difference in Shannon diversity between plant individuals (based solely on Plant_ID characteristics) within Populus at GDD 605 (p=0.739)!
#(c) GDD 1087
shapiro.test(alpha_1087_pop$alphaDiv)
##
## Shapiro-Wilk normality test
##
## data: alpha_1087_pop$alphaDiv
## W = 0.92016, p-value = 0.5065
# p = 0.5065 > 0.05 --> it is NORMAL, so do ANOVA
# Perform ANOVA
anova_shannon_1087_pop <- aov(alphaDiv ~ plant.id, data = alpha_1087_pop)
# Summarize the ANOVA results
summary(anova_shannon_1087_pop)
## Df Sum Sq Mean Sq F value Pr(>F)
## plant.id 1 2.2955 2.2955 12.43 0.0243 *
## Residuals 4 0.7387 0.1847
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Normality of Residuals:
shapiro.test(residuals(anova_shannon_1087_pop)) #p=0.8447 > 0.05 --> it's Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(anova_shannon_1087_pop)
## W = 0.94695, p-value = 0.7155
# Levene Test? Q-Q Plots? Residuals vs. Fitted
THEREFORE: There is NO significant difference in Shannon diversity between individuals within Betula (based solely on indiv. plant characteristics) within Populus at GDD 1087 (p=0.302)!
#(d) GDD 1606
shapiro.test(alpha_1606_pop$alphaDiv)
##
## Shapiro-Wilk normality test
##
## data: alpha_1606_pop$alphaDiv
## W = 0.87935, p-value = 0.3064
# p = 0.3064 > 0.05 --> it is NORMAL, so do ANOVA
# Perform ANOVA
anova_shannon_1606_pop <- aov(alphaDiv ~ plant.id, data = alpha_1606_pop)
# Summarize the ANOVA results
summary(anova_shannon_1606_pop)
## Df Sum Sq Mean Sq F value Pr(>F)
## plant.id 1 0.489 0.4886 0.213 0.676
## Residuals 3 6.890 2.2967
# Normality of Residuals:
shapiro.test(residuals(anova_shannon_1606_pop)) #p=0.4725 > 0.05 --> it's Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(anova_shannon_1606_pop)
## W = 0.91081, p-value = 0.4725
# Levene Test? Q-Q Plots? Residuals vs. Fitted
THEREFORE: There is NO significant difference in Shannon diversity between plant individual (based solely on plant characteristics) within Populus at GDD 1606 (p=0.676)!
#(e) GDD 1992
shapiro.test(alpha_1992_pop$alphaDiv)
##
## Shapiro-Wilk normality test
##
## data: alpha_1992_pop$alphaDiv
## W = 0.85726, p-value = 0.2186
# p = 0.2186 > 0.05 --> it is NORMAL, so do ANOVA
# Perform ANOVA
anova_shannon_1992_pop <- aov(alphaDiv ~ plant.id, data = alpha_1992_pop)
# Summarize the ANOVA results
summary(anova_shannon_1992_pop)
## Df Sum Sq Mean Sq F value Pr(>F)
## plant.id 1 0.1149 0.1149 0.345 0.598
## Residuals 3 1.0005 0.3335
# Normality of Residuals:
shapiro.test(residuals(anova_shannon_1992_pop)) #p=0.7897 > 0.05 --> it's Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(anova_shannon_1992_pop)
## W = 0.95739, p-value = 0.7897
# Levene Test? Q-Q Plots? Residuals vs. Fitted
THEREFORE: There is NO significant difference in Shannon diversity between individual plants (based solely on indiv. plant chars) within Populus at GDD 1992 (p=0.598)!
#(f) GDD 2140
shapiro.test(alpha_2140_pop$alphaDiv)
##
## Shapiro-Wilk normality test
##
## data: alpha_2140_pop$alphaDiv
## W = 0.8641, p-value = 0.2433
# p = 0.2433 > 0.05 --> it is NORMAL, so do ANOVA
# Perform ANOVA
anova_shannon_2140_pop <- aov(alphaDiv ~ plant.id, data = alpha_2140_pop)
# Summarize the ANOVA results
summary(anova_shannon_2140_pop)
## Df Sum Sq Mean Sq F value Pr(>F)
## plant.id 1 0.08131 0.08131 1.083 0.374
## Residuals 3 0.22517 0.07506
# Normality of Residuals:
shapiro.test(residuals(anova_shannon_2140_pop)) #p=0.1633 > 0.05 --> it's Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(anova_shannon_2140_pop)
## W = 0.83942, p-value = 0.1633
# Levene Test? Q-Q Plots? Residuals vs. Fitted
THEREFORE: There is NO significant difference in Shannon diversity between plant individuals (solely based on indiv. plant chars) within Populus at GDD 2140 (p=0.374)!
#(g) GDD 2219
shapiro.test(alpha_2219_pop$alphaDiv)
##
## Shapiro-Wilk normality test
##
## data: alpha_2219_pop$alphaDiv
## W = 0.9104, p-value = 0.47
# p = 0.47 > 0.05 --> it is NORMAL, so do ANOVA
# Perform ANOVA
anova_shannon_2219_pop <- aov(alphaDiv ~ plant.id, data = alpha_2219_pop)
# Summarize the ANOVA results
summary(anova_shannon_2219_pop)
## Df Sum Sq Mean Sq F value Pr(>F)
## plant.id 1 0.1565 0.1565 0.617 0.489
## Residuals 3 0.7607 0.2535
# Normality of Residuals:
shapiro.test(residuals(anova_shannon_2219_pop)) #p=0.416 > 0.05 --> it's Normal!
##
## Shapiro-Wilk normality test
##
## data: residuals(anova_shannon_2219_pop)
## W = 0.90111, p-value = 0.416
# Levene Test? Q-Q Plots? Residuals vs. Fitted
emmeans# Create a column `GDD_5C_bins` to bin (categorize) continuous GDDs
sampling_points <- c(437, 605, 1087, 1606, 1992, 2140, 2219)
asv_scaled_noPlants_Phen_filt_LMM$GDD_5C_bins <- cut(asv_scaled_noPlants_Phen_filt_LMM$GDD_5C,
breaks = c(-Inf, sampling_points, Inf), labels = c("437", "605", "1087", "1606",
"1992", "2140", "2219", "2220+"), include.lowest = TRUE)
# Subset a dataset for each Species
betula_data <- subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia")
populus_data <- subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Populus_tremuloides")
# BETULA ASV RICHNESS PAIRWISE COMPARISONS
# (EMMEANS):#######################################################
# Define the GDD levels of interest
gdd_levels <- c(437, 605, 1087, 1606, 1992, 2140, 2219)
# Run emmeans with specified GDD levels
emm_specnumber_betula <- emmeans(lmm_model_betula_specnumber10, specs = pairwise ~
GDD_5C, at = list(GDD_5C = gdd_levels))
emm_specnumber_betula$emmeans
## GDD_5C emmean SE df lower.CL upper.CL
## 437 0.0458 0.00636 8.23 0.03117 0.0604
## 605 0.0433 0.00605 6.82 0.02891 0.0577
## 1087 0.0362 0.00542 4.46 0.02171 0.0506
## 1606 0.0285 0.00531 4.10 0.01391 0.0431
## 1992 0.0228 0.00562 5.16 0.00847 0.0371
## 2140 0.0206 0.00582 5.92 0.00631 0.0349
## 2219 0.0194 0.00595 6.42 0.00511 0.0338
##
## Degrees-of-freedom method: kenward-roger
## Results are given on the ( (not the response) scale.
## Confidence level used: 0.95
summary(emm_specnumber_betula$contrasts)
## contrast estimate SE df t.ratio p.value
## GDD_5C437 - GDD_5C605 0.00248 0.000595 29 4.172 0.0042
## GDD_5C437 - GDD_5C1087 0.00960 0.002300 29 4.172 0.0042
## GDD_5C437 - GDD_5C1606 0.01727 0.004140 29 4.172 0.0042
## GDD_5C437 - GDD_5C1992 0.02297 0.005500 29 4.172 0.0042
## GDD_5C437 - GDD_5C2140 0.02516 0.006030 29 4.172 0.0042
## GDD_5C437 - GDD_5C2219 0.02632 0.006310 29 4.172 0.0042
## GDD_5C605 - GDD_5C1087 0.00712 0.001710 29 4.172 0.0042
## GDD_5C605 - GDD_5C1606 0.01479 0.003540 29 4.172 0.0042
## GDD_5C605 - GDD_5C1992 0.02049 0.004910 29 4.172 0.0042
## GDD_5C605 - GDD_5C2140 0.02267 0.005430 29 4.172 0.0042
## GDD_5C605 - GDD_5C2219 0.02384 0.005710 29 4.172 0.0042
## GDD_5C1087 - GDD_5C1606 0.00767 0.001840 29 4.172 0.0042
## GDD_5C1087 - GDD_5C1992 0.01337 0.003200 29 4.172 0.0042
## GDD_5C1087 - GDD_5C2140 0.01555 0.003730 29 4.172 0.0042
## GDD_5C1087 - GDD_5C2219 0.01672 0.004010 29 4.172 0.0042
## GDD_5C1606 - GDD_5C1992 0.00570 0.001370 29 4.172 0.0042
## GDD_5C1606 - GDD_5C2140 0.00789 0.001890 29 4.172 0.0042
## GDD_5C1606 - GDD_5C2219 0.00905 0.002170 29 4.172 0.0042
## GDD_5C1992 - GDD_5C2140 0.00219 0.000524 29 4.172 0.0042
## GDD_5C1992 - GDD_5C2219 0.00335 0.000804 29 4.172 0.0042
## GDD_5C2140 - GDD_5C2219 0.00117 0.000280 29 4.172 0.0042
##
## Note: contrasts are still on the ( scale. Consider using
## regrid() if you want contrasts of back-transformed estimates.
## Degrees-of-freedom method: kenward-roger
## P value adjustment: tukey method for comparing a family of 7 estimates
lmm_model_betula_specnumber_GDDcont <- lmer((1/specnumber) ~ GDD_5C + (1 | Plant_ID),
data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia"))
summary(lmm_model_betula_specnumber_GDDcont)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: (1/specnumber) ~ GDD_5C + (1 | Plant_ID)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia")
##
## REML criterion at convergence: -160.3
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.48626 -0.50298 -0.03675 0.52908 2.69893
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0.0001099 0.01048
## Residual 0.0002041 0.01429
## Number of obs: 35, groups: Plant_ID, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 5.222e-02 7.336e-03 1.337e+01 7.118 6.7e-06 ***
## GDD_5C -1.477e-05 3.540e-06 2.900e+01 -4.172 0.00025 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## GDD_5C -0.695
emm_specnumber_betula_GDDcont <- emmeans(lmm_model_betula_specnumber_GDDcont, specs = pairwise ~
GDD_5C)
emm_specnumber_betula_GDDcont$emmeans
## GDD_5C emmean SE df lower.CL upper.CL
## 1441 0.0309 0.00527 4 0.0163 0.0456
##
## Degrees-of-freedom method: kenward-roger
## Results are given on the ( (not the response) scale.
## Confidence level used: 0.95
summary(emm_specnumber_betula_GDDcont$contrasts)
## contrast estimate SE df z.ratio p.value
## (nothing) nonEst NA NA NA NA
##
## Note: contrasts are still on the ( scale. Consider using
## regrid() if you want contrasts of back-transformed estimates.
## Degrees-of-freedom method: kenward-roger
lmm_model_betula_specnumber_GDDbins <- lmer((1/specnumber) ~ GDD_5C_bins + (1 | Plant_ID),
data = subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia"))
summary(lmm_model_betula_specnumber_GDDbins)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: (1/specnumber) ~ GDD_5C_bins + (1 | Plant_ID)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM, Species == "Betula_populifolia")
##
## REML criterion at convergence: -137.3
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.4465 -0.4943 -0.1110 0.4703 2.4799
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0.0001051 0.01025
## Residual 0.0002373 0.01540
## Number of obs: 35, groups: Plant_ID, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 0.046798 0.008275 17.884185 5.655 2.36e-05 ***
## GDD_5C_bins605 -0.006852 0.009742 24.000000 -0.703 0.48859
## GDD_5C_bins1087 -0.006796 0.009742 24.000000 -0.698 0.49211
## GDD_5C_bins1606 -0.018400 0.009742 24.000000 -1.889 0.07107 .
## GDD_5C_bins1992 -0.027851 0.009742 24.000000 -2.859 0.00865 **
## GDD_5C_bins2140 -0.024616 0.009742 24.000000 -2.527 0.01851 *
## GDD_5C_bins2219 -0.026527 0.009742 24.000000 -2.723 0.01186 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C_6 GDD_5C_10 GDD_5C_16 GDD_5C_19 GDD_5C_21
## GDD_5C_b605 -0.589
## GDD_5C_1087 -0.589 0.500
## GDD_5C_1606 -0.589 0.500 0.500
## GDD_5C_1992 -0.589 0.500 0.500 0.500
## GDD_5C_2140 -0.589 0.500 0.500 0.500 0.500
## GDD_5C_2219 -0.589 0.500 0.500 0.500 0.500 0.500
emm_specnumber_betula_GDDbins <- emmeans(lmm_model_betula_specnumber_GDDbins, specs = pairwise ~
GDD_5C_bins)
emm_specnumber_betula_GDDbins$emmeans
## GDD_5C_bins emmean SE df lower.CL upper.CL
## 437 0.0468 0.00827 17.9 0.02940 0.0642
## 605 0.0399 0.00827 17.9 0.02255 0.0573
## 1087 0.0400 0.00827 17.9 0.02261 0.0574
## 1606 0.0284 0.00827 17.9 0.01101 0.0458
## 1992 0.0189 0.00827 17.9 0.00155 0.0363
## 2140 0.0222 0.00827 17.9 0.00479 0.0396
## 2219 0.0203 0.00827 17.9 0.00288 0.0377
##
## Degrees-of-freedom method: kenward-roger
## Results are given on the ( (not the response) scale.
## Confidence level used: 0.95
summary(emm_specnumber_betula_GDDbins$contrasts)
## contrast estimate SE df t.ratio p.value
## GDD_5C_bins437 - GDD_5C_bins605 6.85e-03 0.00974 24 0.703 0.9911
## GDD_5C_bins437 - GDD_5C_bins1087 6.80e-03 0.00974 24 0.698 0.9915
## GDD_5C_bins437 - GDD_5C_bins1606 1.84e-02 0.00974 24 1.889 0.5061
## GDD_5C_bins437 - GDD_5C_bins1992 2.79e-02 0.00974 24 2.859 0.1038
## GDD_5C_bins437 - GDD_5C_bins2140 2.46e-02 0.00974 24 2.527 0.1940
## GDD_5C_bins437 - GDD_5C_bins2219 2.65e-02 0.00974 24 2.723 0.1352
## GDD_5C_bins605 - GDD_5C_bins1087 -5.59e-05 0.00974 24 -0.006 1.0000
## GDD_5C_bins605 - GDD_5C_bins1606 1.15e-02 0.00974 24 1.185 0.8929
## GDD_5C_bins605 - GDD_5C_bins1992 2.10e-02 0.00974 24 2.156 0.3545
## GDD_5C_bins605 - GDD_5C_bins2140 1.78e-02 0.00974 24 1.823 0.5461
## GDD_5C_bins605 - GDD_5C_bins2219 1.97e-02 0.00974 24 2.020 0.4287
## GDD_5C_bins1087 - GDD_5C_bins1606 1.16e-02 0.00974 24 1.191 0.8907
## GDD_5C_bins1087 - GDD_5C_bins1992 2.11e-02 0.00974 24 2.161 0.3515
## GDD_5C_bins1087 - GDD_5C_bins2140 1.78e-02 0.00974 24 1.829 0.5425
## GDD_5C_bins1087 - GDD_5C_bins2219 1.97e-02 0.00974 24 2.025 0.4254
## GDD_5C_bins1606 - GDD_5C_bins1992 9.45e-03 0.00974 24 0.970 0.9557
## GDD_5C_bins1606 - GDD_5C_bins2140 6.22e-03 0.00974 24 0.638 0.9947
## GDD_5C_bins1606 - GDD_5C_bins2219 8.13e-03 0.00974 24 0.834 0.9787
## GDD_5C_bins1992 - GDD_5C_bins2140 -3.24e-03 0.00974 24 -0.332 0.9999
## GDD_5C_bins1992 - GDD_5C_bins2219 -1.32e-03 0.00974 24 -0.136 1.0000
## GDD_5C_bins2140 - GDD_5C_bins2219 1.91e-03 0.00974 24 0.196 1.0000
##
## Note: contrasts are still on the ( scale. Consider using
## regrid() if you want contrasts of back-transformed estimates.
## Degrees-of-freedom method: kenward-roger
## P value adjustment: tukey method for comparing a family of 7 estimates
# Fit new LMM with GDD factor:
# Create a copy of the original data frame
asv_scaled_noPlants_Phen_filt_LMM_factor <- asv_scaled_noPlants_Phen_filt_LMM
# Convert GDD_5C to a factor in the new data frame only
asv_scaled_noPlants_Phen_filt_LMM_factor$GDD_5C <- factor(asv_scaled_noPlants_Phen_filt_LMM_factor$GDD_5C)
lmm_model_betula_specnumber_GDDfactor <- lmer((1/specnumber) ~ GDD_5C + (1 | Plant_ID),
data = subset(asv_scaled_noPlants_Phen_filt_LMM_factor, Species == "Betula_populifolia"))
summary(lmm_model_betula_specnumber_GDDfactor)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: (1/specnumber) ~ GDD_5C + (1 | Plant_ID)
## Data:
## subset(asv_scaled_noPlants_Phen_filt_LMM_factor, Species == "Betula_populifolia")
##
## REML criterion at convergence: -137.3
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.4465 -0.4943 -0.1110 0.4703 2.4799
##
## Random effects:
## Groups Name Variance Std.Dev.
## Plant_ID (Intercept) 0.0001051 0.01025
## Residual 0.0002373 0.01540
## Number of obs: 35, groups: Plant_ID, 5
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 0.046798 0.008275 17.884185 5.655 2.36e-05 ***
## GDD_5C605 -0.006852 0.009742 24.000000 -0.703 0.48859
## GDD_5C1087 -0.006796 0.009742 24.000000 -0.698 0.49211
## GDD_5C1606 -0.018400 0.009742 24.000000 -1.889 0.07107 .
## GDD_5C1992 -0.027851 0.009742 24.000000 -2.859 0.00865 **
## GDD_5C2140 -0.024616 0.009742 24.000000 -2.527 0.01851 *
## GDD_5C2219 -0.026527 0.009742 24.000000 -2.723 0.01186 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) GDD_5C6 GDD_5C10 GDD_5C16 GDD_5C19 GDD_5C21
## GDD_5C605 -0.589
## GDD_5C1087 -0.589 0.500
## GDD_5C1606 -0.589 0.500 0.500
## GDD_5C1992 -0.589 0.500 0.500 0.500
## GDD_5C2140 -0.589 0.500 0.500 0.500 0.500
## GDD_5C2219 -0.589 0.500 0.500 0.500 0.500 0.500
# Run emmeans with specified GDD levels
emm_betula_specnumber_GDDfactor <- emmeans(lmm_model_betula_specnumber_GDDfactor,
specs = pairwise ~ GDD_5C)
emm_betula_specnumber_GDDfactor$emmeans
## GDD_5C emmean SE df lower.CL upper.CL
## 437 0.0468 0.00827 17.9 0.02940 0.0642
## 605 0.0399 0.00827 17.9 0.02255 0.0573
## 1087 0.0400 0.00827 17.9 0.02261 0.0574
## 1606 0.0284 0.00827 17.9 0.01101 0.0458
## 1992 0.0189 0.00827 17.9 0.00155 0.0363
## 2140 0.0222 0.00827 17.9 0.00479 0.0396
## 2219 0.0203 0.00827 17.9 0.00288 0.0377
##
## Degrees-of-freedom method: kenward-roger
## Results are given on the ( (not the response) scale.
## Confidence level used: 0.95
summary(emm_betula_specnumber_GDDfactor$contrasts)
## contrast estimate SE df t.ratio p.value
## GDD_5C437 - GDD_5C605 6.85e-03 0.00974 24 0.703 0.9911
## GDD_5C437 - GDD_5C1087 6.80e-03 0.00974 24 0.698 0.9915
## GDD_5C437 - GDD_5C1606 1.84e-02 0.00974 24 1.889 0.5061
## GDD_5C437 - GDD_5C1992 2.79e-02 0.00974 24 2.859 0.1038
## GDD_5C437 - GDD_5C2140 2.46e-02 0.00974 24 2.527 0.1940
## GDD_5C437 - GDD_5C2219 2.65e-02 0.00974 24 2.723 0.1352
## GDD_5C605 - GDD_5C1087 -5.59e-05 0.00974 24 -0.006 1.0000
## GDD_5C605 - GDD_5C1606 1.15e-02 0.00974 24 1.185 0.8929
## GDD_5C605 - GDD_5C1992 2.10e-02 0.00974 24 2.156 0.3545
## GDD_5C605 - GDD_5C2140 1.78e-02 0.00974 24 1.823 0.5461
## GDD_5C605 - GDD_5C2219 1.97e-02 0.00974 24 2.020 0.4287
## GDD_5C1087 - GDD_5C1606 1.16e-02 0.00974 24 1.191 0.8907
## GDD_5C1087 - GDD_5C1992 2.11e-02 0.00974 24 2.161 0.3515
## GDD_5C1087 - GDD_5C2140 1.78e-02 0.00974 24 1.829 0.5425
## GDD_5C1087 - GDD_5C2219 1.97e-02 0.00974 24 2.025 0.4254
## GDD_5C1606 - GDD_5C1992 9.45e-03 0.00974 24 0.970 0.9557
## GDD_5C1606 - GDD_5C2140 6.22e-03 0.00974 24 0.638 0.9947
## GDD_5C1606 - GDD_5C2219 8.13e-03 0.00974 24 0.834 0.9787
## GDD_5C1992 - GDD_5C2140 -3.24e-03 0.00974 24 -0.332 0.9999
## GDD_5C1992 - GDD_5C2219 -1.32e-03 0.00974 24 -0.136 1.0000
## GDD_5C2140 - GDD_5C2219 1.91e-03 0.00974 24 0.196 1.0000
##
## Note: contrasts are still on the ( scale. Consider using
## regrid() if you want contrasts of back-transformed estimates.
## Degrees-of-freedom method: kenward-roger
## P value adjustment: tukey method for comparing a family of 7 estimates
# BETULA SHANNON DIVERSITY PAIRWISE COMPARISONS
# (EMMEANS):#######################################################
# Define the GDD levels of interest
gdd_levels <- c(437, 605, 1087, 1606, 1992, 2140, 2219)
# Run emmeans with specified GDD levels
emm_shannon_betula <- emmeans(lmm_model_betula_shannon11, specs = pairwise ~ GDD_5C,
at = list(GDD_5C = gdd_levels))
emm_shannon_betula$emmeans
## GDD_5C emmean SE df lower.CL upper.CL
## 437 0.423 0.0471 13.35 0.322 0.525
## 605 0.425 0.0435 10.26 0.329 0.522
## 1087 0.431 0.0358 4.97 0.338 0.523
## 1606 0.436 0.0343 4.20 0.343 0.530
## 1992 0.441 0.0383 6.50 0.348 0.533
## 2140 0.442 0.0408 8.21 0.349 0.536
## 2219 0.443 0.0423 9.34 0.348 0.538
##
## Degrees-of-freedom method: kenward-roger
## Results are given on the ( (not the response) scale.
## Confidence level used: 0.95
summary(emm_shannon_betula$contrasts)
## contrast estimate SE df t.ratio p.value
## GDD_5C437 - GDD_5C605 -0.001868 0.00547 29 -0.341 0.9999
## GDD_5C437 - GDD_5C1087 -0.007227 0.02120 29 -0.341 0.9999
## GDD_5C437 - GDD_5C1606 -0.012998 0.03810 29 -0.341 0.9999
## GDD_5C437 - GDD_5C1992 -0.017289 0.05070 29 -0.341 0.9999
## GDD_5C437 - GDD_5C2140 -0.018935 0.05550 29 -0.341 0.9999
## GDD_5C437 - GDD_5C2219 -0.019813 0.05810 29 -0.341 0.9999
## GDD_5C605 - GDD_5C1087 -0.005359 0.01570 29 -0.341 0.9999
## GDD_5C605 - GDD_5C1606 -0.011130 0.03260 29 -0.341 0.9999
## GDD_5C605 - GDD_5C1992 -0.015421 0.04520 29 -0.341 0.9999
## GDD_5C605 - GDD_5C2140 -0.017067 0.05000 29 -0.341 0.9999
## GDD_5C605 - GDD_5C2219 -0.017945 0.05260 29 -0.341 0.9999
## GDD_5C1087 - GDD_5C1606 -0.005771 0.01690 29 -0.341 0.9999
## GDD_5C1087 - GDD_5C1992 -0.010062 0.02950 29 -0.341 0.9999
## GDD_5C1087 - GDD_5C2140 -0.011708 0.03430 29 -0.341 0.9999
## GDD_5C1087 - GDD_5C2219 -0.012586 0.03690 29 -0.341 0.9999
## GDD_5C1606 - GDD_5C1992 -0.004292 0.01260 29 -0.341 0.9999
## GDD_5C1606 - GDD_5C2140 -0.005937 0.01740 29 -0.341 0.9999
## GDD_5C1606 - GDD_5C2219 -0.006816 0.02000 29 -0.341 0.9999
## GDD_5C1992 - GDD_5C2140 -0.001646 0.00482 29 -0.341 0.9999
## GDD_5C1992 - GDD_5C2219 -0.002524 0.00740 29 -0.341 0.9999
## GDD_5C2140 - GDD_5C2219 -0.000878 0.00257 29 -0.341 0.9999
##
## Note: contrasts are still on the ( scale. Consider using
## regrid() if you want contrasts of back-transformed estimates.
## Degrees-of-freedom method: kenward-roger
## P value adjustment: tukey method for comparing a family of 7 estimates
# POPULUS ASV RICHNESS PAIRWISE COMPARISONS
# (EMMEANS):#######################################################
# Define the GDD levels of interest
gdd_levels <- c(437, 605, 1087, 1606, 1992, 2140, 2219)
# Run emmeans with specified GDD levels
emm_specnumber_populus <- emmeans(lmm_model_populus_specnumber10, specs = pairwise ~
GDD_5C, at = list(GDD_5C = gdd_levels))
emm_specnumber_populus$emmeans
## GDD_5C emmean SE df lower.CL upper.CL
## 437 0.0227 0.00457 16.33 0.0130 0.0324
## 605 0.0231 0.00417 12.32 0.0141 0.0322
## 1087 0.0245 0.00329 5.22 0.0161 0.0328
## 1606 0.0259 0.00313 4.30 0.0174 0.0343
## 1992 0.0269 0.00361 7.53 0.0185 0.0354
## 2140 0.0273 0.00390 9.94 0.0186 0.0360
## 2219 0.0276 0.00407 11.52 0.0186 0.0365
##
## Degrees-of-freedom method: kenward-roger
## Results are given on the ( (not the response) scale.
## Confidence level used: 0.95
summary(emm_specnumber_populus$contrasts)
## contrast estimate SE df t.ratio p.value
## GDD_5C437 - GDD_5C605 -0.000460 0.000572 30 -0.804 0.9827
## GDD_5C437 - GDD_5C1087 -0.001779 0.002210 30 -0.804 0.9827
## GDD_5C437 - GDD_5C1606 -0.003200 0.003980 30 -0.804 0.9827
## GDD_5C437 - GDD_5C1992 -0.004256 0.005290 30 -0.804 0.9827
## GDD_5C437 - GDD_5C2140 -0.004661 0.005790 30 -0.804 0.9827
## GDD_5C437 - GDD_5C2219 -0.004878 0.006060 30 -0.804 0.9827
## GDD_5C605 - GDD_5C1087 -0.001319 0.001640 30 -0.804 0.9827
## GDD_5C605 - GDD_5C1606 -0.002740 0.003410 30 -0.804 0.9827
## GDD_5C605 - GDD_5C1992 -0.003796 0.004720 30 -0.804 0.9827
## GDD_5C605 - GDD_5C2140 -0.004201 0.005220 30 -0.804 0.9827
## GDD_5C605 - GDD_5C2219 -0.004418 0.005490 30 -0.804 0.9827
## GDD_5C1087 - GDD_5C1606 -0.001421 0.001770 30 -0.804 0.9827
## GDD_5C1087 - GDD_5C1992 -0.002477 0.003080 30 -0.804 0.9827
## GDD_5C1087 - GDD_5C2140 -0.002882 0.003580 30 -0.804 0.9827
## GDD_5C1087 - GDD_5C2219 -0.003098 0.003850 30 -0.804 0.9827
## GDD_5C1606 - GDD_5C1992 -0.001057 0.001310 30 -0.804 0.9827
## GDD_5C1606 - GDD_5C2140 -0.001462 0.001820 30 -0.804 0.9827
## GDD_5C1606 - GDD_5C2219 -0.001678 0.002090 30 -0.804 0.9827
## GDD_5C1992 - GDD_5C2140 -0.000405 0.000504 30 -0.804 0.9827
## GDD_5C1992 - GDD_5C2219 -0.000621 0.000772 30 -0.804 0.9827
## GDD_5C2140 - GDD_5C2219 -0.000216 0.000269 30 -0.804 0.9827
##
## Note: contrasts are still on the ( scale. Consider using
## regrid() if you want contrasts of back-transformed estimates.
## Degrees-of-freedom method: kenward-roger
## P value adjustment: tukey method for comparing a family of 7 estimates
# POPULUS SHANNON DIVERSITY PAIRWISE COMPARISONS
# (EMMEANS):#######################################################
# Define the GDD levels of interest
gdd_levels <- c(437, 605, 1087, 1606, 1992, 2140, 2219)
# Run emmeans with specified GDD levels
emm_shannon_populus <- emmeans(lmm_model_populus_shannon15, specs = pairwise ~ GDD_5C,
at = list(GDD_5C = gdd_levels))
emm_shannon_populus$emmeans
## GDD_5C emmean SE df lower.CL upper.CL
## 437 1.84 0.0722 20.94 1.69 1.99
## 605 1.84 0.0648 15.88 1.70 1.97
## 1087 1.83 0.0482 5.74 1.71 1.95
## 1606 1.82 0.0450 4.42 1.70 1.95
## 1992 1.82 0.0544 9.14 1.70 1.94
## 2140 1.82 0.0599 12.65 1.69 1.95
## 2219 1.82 0.0631 14.86 1.68 1.95
##
## Degrees-of-freedom method: kenward-roger
## Results are given on the sqrt (not the response) scale.
## Confidence level used: 0.95
summary(emm_shannon_populus$contrasts)
## contrast estimate SE df t.ratio p.value
## GDD_5C437 - GDD_5C605 0.001757 0.00967 30 0.182 1.0000
## GDD_5C437 - GDD_5C1087 0.006796 0.03740 30 0.182 1.0000
## GDD_5C437 - GDD_5C1606 0.012222 0.06730 30 0.182 1.0000
## GDD_5C437 - GDD_5C1992 0.016258 0.08950 30 0.182 1.0000
## GDD_5C437 - GDD_5C2140 0.017806 0.09800 30 0.182 1.0000
## GDD_5C437 - GDD_5C2219 0.018632 0.10300 30 0.182 1.0000
## GDD_5C605 - GDD_5C1087 0.005040 0.02770 30 0.182 1.0000
## GDD_5C605 - GDD_5C1606 0.010466 0.05760 30 0.182 1.0000
## GDD_5C605 - GDD_5C1992 0.014502 0.07980 30 0.182 1.0000
## GDD_5C605 - GDD_5C2140 0.016049 0.08840 30 0.182 1.0000
## GDD_5C605 - GDD_5C2219 0.016875 0.09290 30 0.182 1.0000
## GDD_5C1087 - GDD_5C1606 0.005426 0.02990 30 0.182 1.0000
## GDD_5C1087 - GDD_5C1992 0.009462 0.05210 30 0.182 1.0000
## GDD_5C1087 - GDD_5C2140 0.011010 0.06060 30 0.182 1.0000
## GDD_5C1087 - GDD_5C2219 0.011836 0.06520 30 0.182 1.0000
## GDD_5C1606 - GDD_5C1992 0.004036 0.02220 30 0.182 1.0000
## GDD_5C1606 - GDD_5C2140 0.005583 0.03070 30 0.182 1.0000
## GDD_5C1606 - GDD_5C2219 0.006409 0.03530 30 0.182 1.0000
## GDD_5C1992 - GDD_5C2140 0.001547 0.00852 30 0.182 1.0000
## GDD_5C1992 - GDD_5C2219 0.002373 0.01310 30 0.182 1.0000
## GDD_5C2140 - GDD_5C2219 0.000826 0.00455 30 0.182 1.0000
##
## Note: contrasts are still on the sqrt scale. Consider using
## regrid() if you want contrasts of back-transformed estimates.
## Degrees-of-freedom method: kenward-roger
## P value adjustment: tukey method for comparing a family of 7 estimates
# FACTORIZED POPULUS SHANNON DIVERSITY PAIRWISE COMPARISONS
# (EMMEANS):#######################################################
# Define the GDD levels of interest gdd_levels <- c(437, 605, 1087, 1606, 1992,
# 2140, 2219)
# Fit new LMM with GDD factor:
lmm_model_populus_shannon_GDDfactor <- lmer(sqrt(alphaDiv) ~ GDD_5C + (1 | Plant_ID),
data = subset(asv_scaled_noPlants_Phen_filt_LMM_factor, Species == "Populus_tremuloides"))
# Run emmeans with specified GDD levels
emm_shannon_populus_GDDfactor <- emmeans(lmm_model_populus_shannon_GDDfactor, specs = pairwise ~
GDD_5C)
emm_shannon_populus_GDDfactor$emmeans
## GDD_5C emmean SE df lower.CL upper.CL
## 437 1.85 0.1030 28.6 1.64 2.06
## 605 1.88 0.1030 28.6 1.67 2.09
## 1087 1.86 0.0958 27.3 1.66 2.05
## 1606 1.59 0.1030 28.6 1.38 1.81
## 1992 1.81 0.1030 28.6 1.59 2.02
## 2140 1.93 0.1030 28.6 1.72 2.14
## 2219 1.86 0.1030 28.6 1.65 2.07
##
## Degrees-of-freedom method: kenward-roger
## Results are given on the sqrt (not the response) scale.
## Confidence level used: 0.95
summary(emm_shannon_populus_GDDfactor$contrasts)
## contrast estimate SE df t.ratio p.value
## GDD_5C437 - GDD_5C605 -0.025657 0.143 25.0 -0.179 1.0000
## GDD_5C437 - GDD_5C1087 -0.004290 0.138 25.3 -0.031 1.0000
## GDD_5C437 - GDD_5C1606 0.258512 0.143 25.0 1.807 0.5555
## GDD_5C437 - GDD_5C1992 0.046989 0.143 25.0 0.329 0.9999
## GDD_5C437 - GDD_5C2140 -0.080090 0.143 25.0 -0.560 0.9974
## GDD_5C437 - GDD_5C2219 -0.004612 0.143 25.0 -0.032 1.0000
## GDD_5C605 - GDD_5C1087 0.021367 0.138 25.3 0.155 1.0000
## GDD_5C605 - GDD_5C1606 0.284169 0.143 25.0 1.987 0.4468
## GDD_5C605 - GDD_5C1992 0.072647 0.143 25.0 0.508 0.9985
## GDD_5C605 - GDD_5C2140 -0.054433 0.143 25.0 -0.381 0.9997
## GDD_5C605 - GDD_5C2219 0.021045 0.143 25.0 0.147 1.0000
## GDD_5C1087 - GDD_5C1606 0.262802 0.138 25.3 1.910 0.4923
## GDD_5C1087 - GDD_5C1992 0.051280 0.138 25.3 0.373 0.9997
## GDD_5C1087 - GDD_5C2140 -0.075800 0.138 25.3 -0.551 0.9976
## GDD_5C1087 - GDD_5C2219 -0.000322 0.138 25.3 -0.002 1.0000
## GDD_5C1606 - GDD_5C1992 -0.211523 0.143 25.0 -1.479 0.7541
## GDD_5C1606 - GDD_5C2140 -0.338602 0.143 25.0 -2.367 0.2533
## GDD_5C1606 - GDD_5C2219 -0.263124 0.143 25.0 -1.840 0.5355
## GDD_5C1992 - GDD_5C2140 -0.127080 0.143 25.0 -0.888 0.9710
## GDD_5C1992 - GDD_5C2219 -0.051602 0.143 25.0 -0.361 0.9998
## GDD_5C2140 - GDD_5C2219 0.075478 0.143 25.0 0.528 0.9981
##
## Note: contrasts are still on the sqrt scale. Consider using
## regrid() if you want contrasts of back-transformed estimates.
## Degrees-of-freedom method: kenward-roger
## P value adjustment: tukey method for comparing a family of 7 estimates
For GDD_5C:
# Filter data for Betula_populifolia
betula_data <- asv_scaled_noPlants_Phen_filt_LMM[asv_scaled_noPlants_Phen_filt_LMM$Species ==
"Betula_populifolia", ]
# gdd_betula <- betula_data$GDD_5C alphaDiv_betula <- betula_data$alphaDiv
# plantid_betula <- betula_data$Plant_ID
# Calculate the multidispersion within data (Calculating significance of
# `GDD_5C`)
phen.disper.betula.gdd = betadisper(dist.mat_betula, betula_data$GDD_5C, type = "centroid")
phen.disper.betula.gdd
##
## Homogeneity of multivariate dispersions
##
## Call: betadisper(d = dist.mat_betula, group = betula_data$GDD_5C, type
## = "centroid")
##
## No. of Positive Eigenvalues: 32
## No. of Negative Eigenvalues: 2
##
## Average distance to centroid:
## 437 605 1087 1606 1992 2140 2219
## 0.5602 0.4245 0.5023 0.4995 0.5171 0.5358 0.3890
##
## Eigenvalues for PCoA axes:
## (Showing 8 of 34 eigenvalues)
## PCoA1 PCoA2 PCoA3 PCoA4 PCoA5 PCoA6 PCoA7 PCoA8
## 3.1523 1.3659 1.0441 0.7518 0.5542 0.5294 0.4525 0.4376
summary(phen.disper.betula.gdd)
## Length Class Mode
## eig 34 -none- numeric
## vectors 1190 -none- numeric
## distances 35 -none- numeric
## group 35 factor numeric
## centroids 238 -none- numeric
## group.distances 7 -none- numeric
## call 4 -none- call
permutest(phen.disper.betula.gdd, permutations = 10000)
##
## Permutation test for homogeneity of multivariate dispersions
## Permutation: free
## Number of permutations: 10000
##
## Response: Distances
## Df Sum Sq Mean Sq F N.Perm Pr(>F)
## Groups 6 0.11243 0.0187387 2.5057 10000 0.0469 *
## Residuals 28 0.20939 0.0074783
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
anova(phen.disper.betula.gdd)
## Analysis of Variance Table
##
## Response: Distances
## Df Sum Sq Mean Sq F value Pr(>F)
## Groups 6 0.11243 0.0187387 2.5057 0.04558 *
## Residuals 28 0.20939 0.0074783
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
plot(phen.disper.betula.gdd)
# Save as PNG
png("betula_disper_gdd_pcoa.png", width = 7, height = 4.85, units = "in", res = 600)
plot(phen.disper.betula.gdd)
dev.off()
boxplot(phen.disper.betula.gdd, xlab = "Growing Degree Days (5°C)")
# Save as PNG
png("betula_disper_gdd_boxplot.png", width = 7, height = 4.85, units = "in", res = 600)
boxplot(phen.disper.betula.gdd, xlab = "Growing Degree Days (5°C)")
dev.off()
TukeyHSD(phen.disper.betula.gdd) #Calculate pairwise difference
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = distances ~ group, data = df)
##
## $group
## diff lwr upr p adj
## 605-437 -0.135643479 -0.30913657 0.037849611 0.2047857
## 1087-437 -0.057909195 -0.23140228 0.115583895 0.9348395
## 1606-437 -0.060725483 -0.23421857 0.112767607 0.9196306
## 1992-437 -0.043053596 -0.21654669 0.130439494 0.9843797
## 2140-437 -0.024440362 -0.19793345 0.149052728 0.9992867
## 2219-437 -0.171215614 -0.34470870 0.002277476 0.0548729
## 1087-605 0.077734284 -0.09575881 0.251227374 0.7859959
## 1606-605 0.074917996 -0.09857509 0.248411086 0.8126763
## 1992-605 0.092589883 -0.08090321 0.266082973 0.6260422
## 2140-605 0.111203117 -0.06228997 0.284696207 0.4174695
## 2219-605 -0.035572135 -0.20906522 0.137920955 0.9942640
## 1606-1087 -0.002816288 -0.17630938 0.170676802 1.0000000
## 1992-1087 0.014855599 -0.15863749 0.188348689 0.9999604
## 2140-1087 0.033468833 -0.14002426 0.206961923 0.9958750
## 2219-1087 -0.113306419 -0.28679951 0.060186671 0.3956368
## 1992-1606 0.017671887 -0.15582120 0.191164977 0.9998903
## 2140-1606 0.036285121 -0.13720797 0.209778211 0.9936198
## 2219-1606 -0.110490131 -0.28398322 0.063002959 0.4249920
## 2140-1992 0.018613234 -0.15487986 0.192106324 0.9998516
## 2219-1992 -0.128162018 -0.30165511 0.045331072 0.2596869
## 2219-2140 -0.146775252 -0.32026834 0.026717838 0.1398592
plot(TukeyHSD(phen.disper.betula.gdd))
# Calculate the multidispersion within data (Calculating significance of
# `Species`)
phen.disper.betula.plantid = betadisper(dist.mat_betula, betula_data$Plant_ID, type = "centroid")
phen.disper.betula.plantid
##
## Homogeneity of multivariate dispersions
##
## Call: betadisper(d = dist.mat_betula, group = betula_data$Plant_ID,
## type = "centroid")
##
## No. of Positive Eigenvalues: 32
## No. of Negative Eigenvalues: 2
##
## Average distance to centroid:
## 8553450 8553606 8553762 8553879 8554325
## 0.5702 0.5681 0.5593 0.5141 0.5378
##
## Eigenvalues for PCoA axes:
## (Showing 8 of 34 eigenvalues)
## PCoA1 PCoA2 PCoA3 PCoA4 PCoA5 PCoA6 PCoA7 PCoA8
## 3.1523 1.3659 1.0441 0.7518 0.5542 0.5294 0.4525 0.4376
summary(phen.disper.betula.plantid)
## Length Class Mode
## eig 34 -none- numeric
## vectors 1190 -none- numeric
## distances 35 -none- numeric
## group 35 factor numeric
## centroids 170 -none- numeric
## group.distances 5 -none- numeric
## call 4 -none- call
# NOTE: The betadisper function calculates the multivariate dispersion
# (variability) within each group of the categorical variable (Plant_ID).
permutest(phen.disper.betula.plantid, permutations = 10000)
##
## Permutation test for homogeneity of multivariate dispersions
## Permutation: free
## Number of permutations: 10000
##
## Response: Distances
## Df Sum Sq Mean Sq F N.Perm Pr(>F)
## Groups 4 0.015835 0.0039589 0.8464 10000 0.5069
## Residuals 30 0.140325 0.0046775
# NOTE:The permutest function performs a permutation test to assess the
# significance of the F-statistic from the betadisper analysis. The results
# include the number of permutations (N.Perm) performed and the p-value
# (Pr(>F)) associated with the permutation test. In this case, the p-value is
# 0.5, indicating that the F-value is not significant.
anova(phen.disper.betula.plantid)
## Analysis of Variance Table
##
## Response: Distances
## Df Sum Sq Mean Sq F value Pr(>F)
## Groups 4 0.015835 0.0039589 0.8464 0.507
## Residuals 30 0.140325 0.0046775
# The anova function provides an ANOVA-like analysis of the dispersion values
# among the groups. Groups F: The F-statistic for testing the null hypothesis
# of equal dispersion among the groups. The F-value is 0.848. Groups Pr(>F):
# The p-value associated with the F-statistic. In this case, the p-value is
# 0.5061, indicating that the differences in dispersion among groups are not
# statistically significant.
plot(phen.disper.betula.plantid)
# Save as PNG
png("betula_disper_plantid_pcoa.png", width = 7, height = 4.85, units = "in", res = 600)
plot(phen.disper.betula.plantid)
dev.off()
boxplot(phen.disper.betula.plantid, xlab = "Plant ID")
# Save as PNG
png("betula_disper_plantid_boxplot.png", width = 7, height = 4.85, units = "in",
res = 600)
boxplot(phen.disper.betula.plantid, xlab = "Plant ID")
dev.off()
TukeyHSD(phen.disper.betula.plantid) #Calculate pairwise difference
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = distances ~ group, data = df)
##
## $group
## diff lwr upr p adj
## 8553606-8553450 -0.002070154 -0.10810812 0.10396782 0.9999975
## 8553762-8553450 -0.010892351 -0.11693032 0.09514562 0.9981823
## 8553879-8553450 -0.056103182 -0.16214115 0.04993479 0.5489792
## 8554325-8553450 -0.032441843 -0.13847981 0.07359613 0.8993028
## 8553762-8553606 -0.008822197 -0.11486017 0.09721577 0.9992051
## 8553879-8553606 -0.054033028 -0.16007100 0.05200494 0.5840548
## 8554325-8553606 -0.030371690 -0.13640966 0.07566628 0.9189118
## 8553879-8553762 -0.045210831 -0.15124880 0.06082714 0.7304058
## 8554325-8553762 -0.021549492 -0.12758746 0.08448848 0.9756285
## 8554325-8553879 0.023661339 -0.08237663 0.12969931 0.9658328
plot(TukeyHSD(phen.disper.betula.plantid))
# Influence taxonomic composition on betadiveristy by GDDs
phen.betula.gdd.adonis2 <- adonis2(dist.mat_betula ~ betula_data$GDD_5C, perm = 10000) #Calculate influence of treatment using community matrix
phen.betula.gdd.adonis2
## Permutation test for adonis under reduced model
## Permutation: free
## Number of permutations: 10000
##
## adonis2(formula = dist.mat_betula ~ betula_data$GDD_5C, permutations = 10000)
## Df SumOfSqs R2 F Pr(>F)
## Model 1 1.8143 0.14952 5.8015 9.999e-05 ***
## Residual 33 10.3203 0.85048
## Total 34 12.1346 1.00000
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Influence taxonomic composition on betadiveristy by Plant_ID
phen.betula.plantid.adonis2 <- adonis2(dist.mat_betula ~ betula_data$Plant_ID, perm = 10000) #Calculate influence of treatment using community matrix
phen.betula.plantid.adonis2
## Permutation test for adonis under reduced model
## Permutation: free
## Number of permutations: 10000
##
## adonis2(formula = dist.mat_betula ~ betula_data$Plant_ID, permutations = 10000)
## Df SumOfSqs R2 F Pr(>F)
## Model 4 1.3944 0.11492 0.9738 0.4984
## Residual 30 10.7401 0.88508
## Total 34 12.1346 1.00000
# 1. Multidispersion Analysis for Interaction (Species & GDDs):
# Calculate multidispersion considering interaction
phen.disper.betula.interact <- betadisper(dist.mat_betula, interaction(betula_data$GDD_5C,
betula_data$Plant_ID), type = "centroid")
# 2. Permutation Test for Interaction:
permutest(phen.disper.betula.interact, permutations = 10000)
##
## Permutation test for homogeneity of multivariate dispersions
## Permutation: free
## Number of permutations: 10000
##
## Response: Distances
## Df Sum Sq Mean Sq F N.Perm Pr(>F)
## Groups 34 0 0 NaN 10000
## Residuals 0 0 NaN
# 3. ANOVA-Like Analysis for Interaction:
anova(phen.disper.betula.interact)
## Analysis of Variance Table
##
## Response: Distances
## Df Sum Sq Mean Sq F value Pr(>F)
## Groups 34 0 0 NaN NaN
## Residuals 0 0 NaN
plot(phen.disper.betula.interact)
## Warning in plot.xy(xy.coords(x, y), type = type, ...): unimplemented pch value
## '31'
## Warning in plot.xy(xy.coords(x, y), type = type, ...): unimplemented pch value
## '30'
## Warning in plot.xy(xy.coords(x, y), type = type, ...): unimplemented pch value
## '27'
## Warning in plot.xy(xy.coords(x, y), type = type, ...): unimplemented pch value
## '28'
## Warning in plot.xy(xy.coords(x, y), type = type, ...): unimplemented pch value
## '29'
## Warning in plot.xy(xy.coords(x, y), type = type, ...): unimplemented pch value
## '26'
# Post-hoc Pairwise Comparisons for Interaction
pairwise_dispersion_betula_interact <- TukeyHSD(phen.disper.betula.interact)
## Warning in qtukey(conf.level, length(means), x$df.residual): NaNs produced
head(pairwise_dispersion_betula_interact)
## $group
## diff lwr upr p adj
## 605.8553450-437.8553450 0 NaN NaN NaN
## 1087.8553450-437.8553450 0 NaN NaN NaN
## 1606.8553450-437.8553450 0 NaN NaN NaN
## 1992.8553450-437.8553450 0 NaN NaN NaN
## 2140.8553450-437.8553450 0 NaN NaN NaN
## 2219.8553450-437.8553450 0 NaN NaN NaN
## 437.8553606-437.8553450 0 NaN NaN NaN
## 605.8553606-437.8553450 0 NaN NaN NaN
## 1087.8553606-437.8553450 0 NaN NaN NaN
## 1606.8553606-437.8553450 0 NaN NaN NaN
## 1992.8553606-437.8553450 0 NaN NaN NaN
## 2140.8553606-437.8553450 0 NaN NaN NaN
## 2219.8553606-437.8553450 0 NaN NaN NaN
## 437.8553762-437.8553450 0 NaN NaN NaN
## 605.8553762-437.8553450 0 NaN NaN NaN
## 1087.8553762-437.8553450 0 NaN NaN NaN
## 1606.8553762-437.8553450 0 NaN NaN NaN
## 1992.8553762-437.8553450 0 NaN NaN NaN
## 2140.8553762-437.8553450 0 NaN NaN NaN
## 2219.8553762-437.8553450 0 NaN NaN NaN
## 437.8553879-437.8553450 0 NaN NaN NaN
## 605.8553879-437.8553450 0 NaN NaN NaN
## 1087.8553879-437.8553450 0 NaN NaN NaN
## 1606.8553879-437.8553450 0 NaN NaN NaN
## 1992.8553879-437.8553450 0 NaN NaN NaN
## 2140.8553879-437.8553450 0 NaN NaN NaN
## 2219.8553879-437.8553450 0 NaN NaN NaN
## 437.8554325-437.8553450 0 NaN NaN NaN
## 605.8554325-437.8553450 0 NaN NaN NaN
## 1087.8554325-437.8553450 0 NaN NaN NaN
## 1606.8554325-437.8553450 0 NaN NaN NaN
## 1992.8554325-437.8553450 0 NaN NaN NaN
## 2140.8554325-437.8553450 0 NaN NaN NaN
## 2219.8554325-437.8553450 0 NaN NaN NaN
## 1087.8553450-605.8553450 0 NaN NaN NaN
## 1606.8553450-605.8553450 0 NaN NaN NaN
## 1992.8553450-605.8553450 0 NaN NaN NaN
## 2140.8553450-605.8553450 0 NaN NaN NaN
## 2219.8553450-605.8553450 0 NaN NaN NaN
## 437.8553606-605.8553450 0 NaN NaN NaN
## 605.8553606-605.8553450 0 NaN NaN NaN
## 1087.8553606-605.8553450 0 NaN NaN NaN
## 1606.8553606-605.8553450 0 NaN NaN NaN
## 1992.8553606-605.8553450 0 NaN NaN NaN
## 2140.8553606-605.8553450 0 NaN NaN NaN
## 2219.8553606-605.8553450 0 NaN NaN NaN
## 437.8553762-605.8553450 0 NaN NaN NaN
## 605.8553762-605.8553450 0 NaN NaN NaN
## 1087.8553762-605.8553450 0 NaN NaN NaN
## 1606.8553762-605.8553450 0 NaN NaN NaN
## 1992.8553762-605.8553450 0 NaN NaN NaN
## 2140.8553762-605.8553450 0 NaN NaN NaN
## 2219.8553762-605.8553450 0 NaN NaN NaN
## 437.8553879-605.8553450 0 NaN NaN NaN
## 605.8553879-605.8553450 0 NaN NaN NaN
## 1087.8553879-605.8553450 0 NaN NaN NaN
## 1606.8553879-605.8553450 0 NaN NaN NaN
## 1992.8553879-605.8553450 0 NaN NaN NaN
## 2140.8553879-605.8553450 0 NaN NaN NaN
## 2219.8553879-605.8553450 0 NaN NaN NaN
## 437.8554325-605.8553450 0 NaN NaN NaN
## 605.8554325-605.8553450 0 NaN NaN NaN
## 1087.8554325-605.8553450 0 NaN NaN NaN
## 1606.8554325-605.8553450 0 NaN NaN NaN
## 1992.8554325-605.8553450 0 NaN NaN NaN
## 2140.8554325-605.8553450 0 NaN NaN NaN
## 2219.8554325-605.8553450 0 NaN NaN NaN
## 1606.8553450-1087.8553450 0 NaN NaN NaN
## 1992.8553450-1087.8553450 0 NaN NaN NaN
## 2140.8553450-1087.8553450 0 NaN NaN NaN
## 2219.8553450-1087.8553450 0 NaN NaN NaN
## 437.8553606-1087.8553450 0 NaN NaN NaN
## 605.8553606-1087.8553450 0 NaN NaN NaN
## 1087.8553606-1087.8553450 0 NaN NaN NaN
## 1606.8553606-1087.8553450 0 NaN NaN NaN
## 1992.8553606-1087.8553450 0 NaN NaN NaN
## 2140.8553606-1087.8553450 0 NaN NaN NaN
## 2219.8553606-1087.8553450 0 NaN NaN NaN
## 437.8553762-1087.8553450 0 NaN NaN NaN
## 605.8553762-1087.8553450 0 NaN NaN NaN
## 1087.8553762-1087.8553450 0 NaN NaN NaN
## 1606.8553762-1087.8553450 0 NaN NaN NaN
## 1992.8553762-1087.8553450 0 NaN NaN NaN
## 2140.8553762-1087.8553450 0 NaN NaN NaN
## 2219.8553762-1087.8553450 0 NaN NaN NaN
## 437.8553879-1087.8553450 0 NaN NaN NaN
## 605.8553879-1087.8553450 0 NaN NaN NaN
## 1087.8553879-1087.8553450 0 NaN NaN NaN
## 1606.8553879-1087.8553450 0 NaN NaN NaN
## 1992.8553879-1087.8553450 0 NaN NaN NaN
## 2140.8553879-1087.8553450 0 NaN NaN NaN
## 2219.8553879-1087.8553450 0 NaN NaN NaN
## 437.8554325-1087.8553450 0 NaN NaN NaN
## 605.8554325-1087.8553450 0 NaN NaN NaN
## 1087.8554325-1087.8553450 0 NaN NaN NaN
## 1606.8554325-1087.8553450 0 NaN NaN NaN
## 1992.8554325-1087.8553450 0 NaN NaN NaN
## 2140.8554325-1087.8553450 0 NaN NaN NaN
## 2219.8554325-1087.8553450 0 NaN NaN NaN
## 1992.8553450-1606.8553450 0 NaN NaN NaN
## 2140.8553450-1606.8553450 0 NaN NaN NaN
## 2219.8553450-1606.8553450 0 NaN NaN NaN
## 437.8553606-1606.8553450 0 NaN NaN NaN
## 605.8553606-1606.8553450 0 NaN NaN NaN
## 1087.8553606-1606.8553450 0 NaN NaN NaN
## 1606.8553606-1606.8553450 0 NaN NaN NaN
## 1992.8553606-1606.8553450 0 NaN NaN NaN
## 2140.8553606-1606.8553450 0 NaN NaN NaN
## 2219.8553606-1606.8553450 0 NaN NaN NaN
## 437.8553762-1606.8553450 0 NaN NaN NaN
## 605.8553762-1606.8553450 0 NaN NaN NaN
## 1087.8553762-1606.8553450 0 NaN NaN NaN
## 1606.8553762-1606.8553450 0 NaN NaN NaN
## 1992.8553762-1606.8553450 0 NaN NaN NaN
## 2140.8553762-1606.8553450 0 NaN NaN NaN
## 2219.8553762-1606.8553450 0 NaN NaN NaN
## 437.8553879-1606.8553450 0 NaN NaN NaN
## 605.8553879-1606.8553450 0 NaN NaN NaN
## 1087.8553879-1606.8553450 0 NaN NaN NaN
## 1606.8553879-1606.8553450 0 NaN NaN NaN
## 1992.8553879-1606.8553450 0 NaN NaN NaN
## 2140.8553879-1606.8553450 0 NaN NaN NaN
## 2219.8553879-1606.8553450 0 NaN NaN NaN
## 437.8554325-1606.8553450 0 NaN NaN NaN
## 605.8554325-1606.8553450 0 NaN NaN NaN
## 1087.8554325-1606.8553450 0 NaN NaN NaN
## 1606.8554325-1606.8553450 0 NaN NaN NaN
## 1992.8554325-1606.8553450 0 NaN NaN NaN
## 2140.8554325-1606.8553450 0 NaN NaN NaN
## 2219.8554325-1606.8553450 0 NaN NaN NaN
## 2140.8553450-1992.8553450 0 NaN NaN NaN
## 2219.8553450-1992.8553450 0 NaN NaN NaN
## 437.8553606-1992.8553450 0 NaN NaN NaN
## 605.8553606-1992.8553450 0 NaN NaN NaN
## 1087.8553606-1992.8553450 0 NaN NaN NaN
## 1606.8553606-1992.8553450 0 NaN NaN NaN
## 1992.8553606-1992.8553450 0 NaN NaN NaN
## 2140.8553606-1992.8553450 0 NaN NaN NaN
## 2219.8553606-1992.8553450 0 NaN NaN NaN
## 437.8553762-1992.8553450 0 NaN NaN NaN
## 605.8553762-1992.8553450 0 NaN NaN NaN
## 1087.8553762-1992.8553450 0 NaN NaN NaN
## 1606.8553762-1992.8553450 0 NaN NaN NaN
## 1992.8553762-1992.8553450 0 NaN NaN NaN
## 2140.8553762-1992.8553450 0 NaN NaN NaN
## 2219.8553762-1992.8553450 0 NaN NaN NaN
## 437.8553879-1992.8553450 0 NaN NaN NaN
## 605.8553879-1992.8553450 0 NaN NaN NaN
## 1087.8553879-1992.8553450 0 NaN NaN NaN
## 1606.8553879-1992.8553450 0 NaN NaN NaN
## 1992.8553879-1992.8553450 0 NaN NaN NaN
## 2140.8553879-1992.8553450 0 NaN NaN NaN
## 2219.8553879-1992.8553450 0 NaN NaN NaN
## 437.8554325-1992.8553450 0 NaN NaN NaN
## 605.8554325-1992.8553450 0 NaN NaN NaN
## 1087.8554325-1992.8553450 0 NaN NaN NaN
## 1606.8554325-1992.8553450 0 NaN NaN NaN
## 1992.8554325-1992.8553450 0 NaN NaN NaN
## 2140.8554325-1992.8553450 0 NaN NaN NaN
## 2219.8554325-1992.8553450 0 NaN NaN NaN
## 2219.8553450-2140.8553450 0 NaN NaN NaN
## 437.8553606-2140.8553450 0 NaN NaN NaN
## 605.8553606-2140.8553450 0 NaN NaN NaN
## 1087.8553606-2140.8553450 0 NaN NaN NaN
## 1606.8553606-2140.8553450 0 NaN NaN NaN
## 1992.8553606-2140.8553450 0 NaN NaN NaN
## 2140.8553606-2140.8553450 0 NaN NaN NaN
## 2219.8553606-2140.8553450 0 NaN NaN NaN
## 437.8553762-2140.8553450 0 NaN NaN NaN
## 605.8553762-2140.8553450 0 NaN NaN NaN
## 1087.8553762-2140.8553450 0 NaN NaN NaN
## 1606.8553762-2140.8553450 0 NaN NaN NaN
## 1992.8553762-2140.8553450 0 NaN NaN NaN
## 2140.8553762-2140.8553450 0 NaN NaN NaN
## 2219.8553762-2140.8553450 0 NaN NaN NaN
## 437.8553879-2140.8553450 0 NaN NaN NaN
## 605.8553879-2140.8553450 0 NaN NaN NaN
## 1087.8553879-2140.8553450 0 NaN NaN NaN
## 1606.8553879-2140.8553450 0 NaN NaN NaN
## 1992.8553879-2140.8553450 0 NaN NaN NaN
## 2140.8553879-2140.8553450 0 NaN NaN NaN
## 2219.8553879-2140.8553450 0 NaN NaN NaN
## 437.8554325-2140.8553450 0 NaN NaN NaN
## 605.8554325-2140.8553450 0 NaN NaN NaN
## 1087.8554325-2140.8553450 0 NaN NaN NaN
## 1606.8554325-2140.8553450 0 NaN NaN NaN
## 1992.8554325-2140.8553450 0 NaN NaN NaN
## 2140.8554325-2140.8553450 0 NaN NaN NaN
## 2219.8554325-2140.8553450 0 NaN NaN NaN
## 437.8553606-2219.8553450 0 NaN NaN NaN
## 605.8553606-2219.8553450 0 NaN NaN NaN
## 1087.8553606-2219.8553450 0 NaN NaN NaN
## 1606.8553606-2219.8553450 0 NaN NaN NaN
## 1992.8553606-2219.8553450 0 NaN NaN NaN
## 2140.8553606-2219.8553450 0 NaN NaN NaN
## 2219.8553606-2219.8553450 0 NaN NaN NaN
## 437.8553762-2219.8553450 0 NaN NaN NaN
## 605.8553762-2219.8553450 0 NaN NaN NaN
## 1087.8553762-2219.8553450 0 NaN NaN NaN
## 1606.8553762-2219.8553450 0 NaN NaN NaN
## 1992.8553762-2219.8553450 0 NaN NaN NaN
## 2140.8553762-2219.8553450 0 NaN NaN NaN
## 2219.8553762-2219.8553450 0 NaN NaN NaN
## 437.8553879-2219.8553450 0 NaN NaN NaN
## 605.8553879-2219.8553450 0 NaN NaN NaN
## 1087.8553879-2219.8553450 0 NaN NaN NaN
## 1606.8553879-2219.8553450 0 NaN NaN NaN
## 1992.8553879-2219.8553450 0 NaN NaN NaN
## 2140.8553879-2219.8553450 0 NaN NaN NaN
## 2219.8553879-2219.8553450 0 NaN NaN NaN
## 437.8554325-2219.8553450 0 NaN NaN NaN
## 605.8554325-2219.8553450 0 NaN NaN NaN
## 1087.8554325-2219.8553450 0 NaN NaN NaN
## 1606.8554325-2219.8553450 0 NaN NaN NaN
## 1992.8554325-2219.8553450 0 NaN NaN NaN
## 2140.8554325-2219.8553450 0 NaN NaN NaN
## 2219.8554325-2219.8553450 0 NaN NaN NaN
## 605.8553606-437.8553606 0 NaN NaN NaN
## 1087.8553606-437.8553606 0 NaN NaN NaN
## 1606.8553606-437.8553606 0 NaN NaN NaN
## 1992.8553606-437.8553606 0 NaN NaN NaN
## 2140.8553606-437.8553606 0 NaN NaN NaN
## 2219.8553606-437.8553606 0 NaN NaN NaN
## 437.8553762-437.8553606 0 NaN NaN NaN
## 605.8553762-437.8553606 0 NaN NaN NaN
## 1087.8553762-437.8553606 0 NaN NaN NaN
## 1606.8553762-437.8553606 0 NaN NaN NaN
## 1992.8553762-437.8553606 0 NaN NaN NaN
## 2140.8553762-437.8553606 0 NaN NaN NaN
## 2219.8553762-437.8553606 0 NaN NaN NaN
## 437.8553879-437.8553606 0 NaN NaN NaN
## 605.8553879-437.8553606 0 NaN NaN NaN
## 1087.8553879-437.8553606 0 NaN NaN NaN
## 1606.8553879-437.8553606 0 NaN NaN NaN
## 1992.8553879-437.8553606 0 NaN NaN NaN
## 2140.8553879-437.8553606 0 NaN NaN NaN
## 2219.8553879-437.8553606 0 NaN NaN NaN
## 437.8554325-437.8553606 0 NaN NaN NaN
## 605.8554325-437.8553606 0 NaN NaN NaN
## 1087.8554325-437.8553606 0 NaN NaN NaN
## 1606.8554325-437.8553606 0 NaN NaN NaN
## 1992.8554325-437.8553606 0 NaN NaN NaN
## 2140.8554325-437.8553606 0 NaN NaN NaN
## 2219.8554325-437.8553606 0 NaN NaN NaN
## 1087.8553606-605.8553606 0 NaN NaN NaN
## 1606.8553606-605.8553606 0 NaN NaN NaN
## 1992.8553606-605.8553606 0 NaN NaN NaN
## 2140.8553606-605.8553606 0 NaN NaN NaN
## 2219.8553606-605.8553606 0 NaN NaN NaN
## 437.8553762-605.8553606 0 NaN NaN NaN
## 605.8553762-605.8553606 0 NaN NaN NaN
## 1087.8553762-605.8553606 0 NaN NaN NaN
## 1606.8553762-605.8553606 0 NaN NaN NaN
## 1992.8553762-605.8553606 0 NaN NaN NaN
## 2140.8553762-605.8553606 0 NaN NaN NaN
## 2219.8553762-605.8553606 0 NaN NaN NaN
## 437.8553879-605.8553606 0 NaN NaN NaN
## 605.8553879-605.8553606 0 NaN NaN NaN
## 1087.8553879-605.8553606 0 NaN NaN NaN
## 1606.8553879-605.8553606 0 NaN NaN NaN
## 1992.8553879-605.8553606 0 NaN NaN NaN
## 2140.8553879-605.8553606 0 NaN NaN NaN
## 2219.8553879-605.8553606 0 NaN NaN NaN
## 437.8554325-605.8553606 0 NaN NaN NaN
## 605.8554325-605.8553606 0 NaN NaN NaN
## 1087.8554325-605.8553606 0 NaN NaN NaN
## 1606.8554325-605.8553606 0 NaN NaN NaN
## 1992.8554325-605.8553606 0 NaN NaN NaN
## 2140.8554325-605.8553606 0 NaN NaN NaN
## 2219.8554325-605.8553606 0 NaN NaN NaN
## 1606.8553606-1087.8553606 0 NaN NaN NaN
## 1992.8553606-1087.8553606 0 NaN NaN NaN
## 2140.8553606-1087.8553606 0 NaN NaN NaN
## 2219.8553606-1087.8553606 0 NaN NaN NaN
## 437.8553762-1087.8553606 0 NaN NaN NaN
## 605.8553762-1087.8553606 0 NaN NaN NaN
## 1087.8553762-1087.8553606 0 NaN NaN NaN
## 1606.8553762-1087.8553606 0 NaN NaN NaN
## 1992.8553762-1087.8553606 0 NaN NaN NaN
## 2140.8553762-1087.8553606 0 NaN NaN NaN
## 2219.8553762-1087.8553606 0 NaN NaN NaN
## 437.8553879-1087.8553606 0 NaN NaN NaN
## 605.8553879-1087.8553606 0 NaN NaN NaN
## 1087.8553879-1087.8553606 0 NaN NaN NaN
## 1606.8553879-1087.8553606 0 NaN NaN NaN
## 1992.8553879-1087.8553606 0 NaN NaN NaN
## 2140.8553879-1087.8553606 0 NaN NaN NaN
## 2219.8553879-1087.8553606 0 NaN NaN NaN
## 437.8554325-1087.8553606 0 NaN NaN NaN
## 605.8554325-1087.8553606 0 NaN NaN NaN
## 1087.8554325-1087.8553606 0 NaN NaN NaN
## 1606.8554325-1087.8553606 0 NaN NaN NaN
## 1992.8554325-1087.8553606 0 NaN NaN NaN
## 2140.8554325-1087.8553606 0 NaN NaN NaN
## 2219.8554325-1087.8553606 0 NaN NaN NaN
## 1992.8553606-1606.8553606 0 NaN NaN NaN
## 2140.8553606-1606.8553606 0 NaN NaN NaN
## 2219.8553606-1606.8553606 0 NaN NaN NaN
## 437.8553762-1606.8553606 0 NaN NaN NaN
## 605.8553762-1606.8553606 0 NaN NaN NaN
## 1087.8553762-1606.8553606 0 NaN NaN NaN
## 1606.8553762-1606.8553606 0 NaN NaN NaN
## 1992.8553762-1606.8553606 0 NaN NaN NaN
## 2140.8553762-1606.8553606 0 NaN NaN NaN
## 2219.8553762-1606.8553606 0 NaN NaN NaN
## 437.8553879-1606.8553606 0 NaN NaN NaN
## 605.8553879-1606.8553606 0 NaN NaN NaN
## 1087.8553879-1606.8553606 0 NaN NaN NaN
## 1606.8553879-1606.8553606 0 NaN NaN NaN
## 1992.8553879-1606.8553606 0 NaN NaN NaN
## 2140.8553879-1606.8553606 0 NaN NaN NaN
## 2219.8553879-1606.8553606 0 NaN NaN NaN
## 437.8554325-1606.8553606 0 NaN NaN NaN
## 605.8554325-1606.8553606 0 NaN NaN NaN
## 1087.8554325-1606.8553606 0 NaN NaN NaN
## 1606.8554325-1606.8553606 0 NaN NaN NaN
## 1992.8554325-1606.8553606 0 NaN NaN NaN
## 2140.8554325-1606.8553606 0 NaN NaN NaN
## 2219.8554325-1606.8553606 0 NaN NaN NaN
## 2140.8553606-1992.8553606 0 NaN NaN NaN
## 2219.8553606-1992.8553606 0 NaN NaN NaN
## 437.8553762-1992.8553606 0 NaN NaN NaN
## 605.8553762-1992.8553606 0 NaN NaN NaN
## 1087.8553762-1992.8553606 0 NaN NaN NaN
## 1606.8553762-1992.8553606 0 NaN NaN NaN
## 1992.8553762-1992.8553606 0 NaN NaN NaN
## 2140.8553762-1992.8553606 0 NaN NaN NaN
## 2219.8553762-1992.8553606 0 NaN NaN NaN
## 437.8553879-1992.8553606 0 NaN NaN NaN
## 605.8553879-1992.8553606 0 NaN NaN NaN
## 1087.8553879-1992.8553606 0 NaN NaN NaN
## 1606.8553879-1992.8553606 0 NaN NaN NaN
## 1992.8553879-1992.8553606 0 NaN NaN NaN
## 2140.8553879-1992.8553606 0 NaN NaN NaN
## 2219.8553879-1992.8553606 0 NaN NaN NaN
## 437.8554325-1992.8553606 0 NaN NaN NaN
## 605.8554325-1992.8553606 0 NaN NaN NaN
## 1087.8554325-1992.8553606 0 NaN NaN NaN
## 1606.8554325-1992.8553606 0 NaN NaN NaN
## 1992.8554325-1992.8553606 0 NaN NaN NaN
## 2140.8554325-1992.8553606 0 NaN NaN NaN
## 2219.8554325-1992.8553606 0 NaN NaN NaN
## 2219.8553606-2140.8553606 0 NaN NaN NaN
## 437.8553762-2140.8553606 0 NaN NaN NaN
## 605.8553762-2140.8553606 0 NaN NaN NaN
## 1087.8553762-2140.8553606 0 NaN NaN NaN
## 1606.8553762-2140.8553606 0 NaN NaN NaN
## 1992.8553762-2140.8553606 0 NaN NaN NaN
## 2140.8553762-2140.8553606 0 NaN NaN NaN
## 2219.8553762-2140.8553606 0 NaN NaN NaN
## 437.8553879-2140.8553606 0 NaN NaN NaN
## 605.8553879-2140.8553606 0 NaN NaN NaN
## 1087.8553879-2140.8553606 0 NaN NaN NaN
## 1606.8553879-2140.8553606 0 NaN NaN NaN
## 1992.8553879-2140.8553606 0 NaN NaN NaN
## 2140.8553879-2140.8553606 0 NaN NaN NaN
## 2219.8553879-2140.8553606 0 NaN NaN NaN
## 437.8554325-2140.8553606 0 NaN NaN NaN
## 605.8554325-2140.8553606 0 NaN NaN NaN
## 1087.8554325-2140.8553606 0 NaN NaN NaN
## 1606.8554325-2140.8553606 0 NaN NaN NaN
## 1992.8554325-2140.8553606 0 NaN NaN NaN
## 2140.8554325-2140.8553606 0 NaN NaN NaN
## 2219.8554325-2140.8553606 0 NaN NaN NaN
## 437.8553762-2219.8553606 0 NaN NaN NaN
## 605.8553762-2219.8553606 0 NaN NaN NaN
## 1087.8553762-2219.8553606 0 NaN NaN NaN
## 1606.8553762-2219.8553606 0 NaN NaN NaN
## 1992.8553762-2219.8553606 0 NaN NaN NaN
## 2140.8553762-2219.8553606 0 NaN NaN NaN
## 2219.8553762-2219.8553606 0 NaN NaN NaN
## 437.8553879-2219.8553606 0 NaN NaN NaN
## 605.8553879-2219.8553606 0 NaN NaN NaN
## 1087.8553879-2219.8553606 0 NaN NaN NaN
## 1606.8553879-2219.8553606 0 NaN NaN NaN
## 1992.8553879-2219.8553606 0 NaN NaN NaN
## 2140.8553879-2219.8553606 0 NaN NaN NaN
## 2219.8553879-2219.8553606 0 NaN NaN NaN
## 437.8554325-2219.8553606 0 NaN NaN NaN
## 605.8554325-2219.8553606 0 NaN NaN NaN
## 1087.8554325-2219.8553606 0 NaN NaN NaN
## 1606.8554325-2219.8553606 0 NaN NaN NaN
## 1992.8554325-2219.8553606 0 NaN NaN NaN
## 2140.8554325-2219.8553606 0 NaN NaN NaN
## 2219.8554325-2219.8553606 0 NaN NaN NaN
## 605.8553762-437.8553762 0 NaN NaN NaN
## 1087.8553762-437.8553762 0 NaN NaN NaN
## 1606.8553762-437.8553762 0 NaN NaN NaN
## 1992.8553762-437.8553762 0 NaN NaN NaN
## 2140.8553762-437.8553762 0 NaN NaN NaN
## 2219.8553762-437.8553762 0 NaN NaN NaN
## 437.8553879-437.8553762 0 NaN NaN NaN
## 605.8553879-437.8553762 0 NaN NaN NaN
## 1087.8553879-437.8553762 0 NaN NaN NaN
## 1606.8553879-437.8553762 0 NaN NaN NaN
## 1992.8553879-437.8553762 0 NaN NaN NaN
## 2140.8553879-437.8553762 0 NaN NaN NaN
## 2219.8553879-437.8553762 0 NaN NaN NaN
## 437.8554325-437.8553762 0 NaN NaN NaN
## 605.8554325-437.8553762 0 NaN NaN NaN
## 1087.8554325-437.8553762 0 NaN NaN NaN
## 1606.8554325-437.8553762 0 NaN NaN NaN
## 1992.8554325-437.8553762 0 NaN NaN NaN
## 2140.8554325-437.8553762 0 NaN NaN NaN
## 2219.8554325-437.8553762 0 NaN NaN NaN
## 1087.8553762-605.8553762 0 NaN NaN NaN
## 1606.8553762-605.8553762 0 NaN NaN NaN
## 1992.8553762-605.8553762 0 NaN NaN NaN
## 2140.8553762-605.8553762 0 NaN NaN NaN
## 2219.8553762-605.8553762 0 NaN NaN NaN
## 437.8553879-605.8553762 0 NaN NaN NaN
## 605.8553879-605.8553762 0 NaN NaN NaN
## 1087.8553879-605.8553762 0 NaN NaN NaN
## 1606.8553879-605.8553762 0 NaN NaN NaN
## 1992.8553879-605.8553762 0 NaN NaN NaN
## 2140.8553879-605.8553762 0 NaN NaN NaN
## 2219.8553879-605.8553762 0 NaN NaN NaN
## 437.8554325-605.8553762 0 NaN NaN NaN
## 605.8554325-605.8553762 0 NaN NaN NaN
## 1087.8554325-605.8553762 0 NaN NaN NaN
## 1606.8554325-605.8553762 0 NaN NaN NaN
## 1992.8554325-605.8553762 0 NaN NaN NaN
## 2140.8554325-605.8553762 0 NaN NaN NaN
## 2219.8554325-605.8553762 0 NaN NaN NaN
## 1606.8553762-1087.8553762 0 NaN NaN NaN
## 1992.8553762-1087.8553762 0 NaN NaN NaN
## 2140.8553762-1087.8553762 0 NaN NaN NaN
## 2219.8553762-1087.8553762 0 NaN NaN NaN
## 437.8553879-1087.8553762 0 NaN NaN NaN
## 605.8553879-1087.8553762 0 NaN NaN NaN
## 1087.8553879-1087.8553762 0 NaN NaN NaN
## 1606.8553879-1087.8553762 0 NaN NaN NaN
## 1992.8553879-1087.8553762 0 NaN NaN NaN
## 2140.8553879-1087.8553762 0 NaN NaN NaN
## 2219.8553879-1087.8553762 0 NaN NaN NaN
## 437.8554325-1087.8553762 0 NaN NaN NaN
## 605.8554325-1087.8553762 0 NaN NaN NaN
## 1087.8554325-1087.8553762 0 NaN NaN NaN
## 1606.8554325-1087.8553762 0 NaN NaN NaN
## 1992.8554325-1087.8553762 0 NaN NaN NaN
## 2140.8554325-1087.8553762 0 NaN NaN NaN
## 2219.8554325-1087.8553762 0 NaN NaN NaN
## 1992.8553762-1606.8553762 0 NaN NaN NaN
## 2140.8553762-1606.8553762 0 NaN NaN NaN
## 2219.8553762-1606.8553762 0 NaN NaN NaN
## 437.8553879-1606.8553762 0 NaN NaN NaN
## 605.8553879-1606.8553762 0 NaN NaN NaN
## 1087.8553879-1606.8553762 0 NaN NaN NaN
## 1606.8553879-1606.8553762 0 NaN NaN NaN
## 1992.8553879-1606.8553762 0 NaN NaN NaN
## 2140.8553879-1606.8553762 0 NaN NaN NaN
## 2219.8553879-1606.8553762 0 NaN NaN NaN
## 437.8554325-1606.8553762 0 NaN NaN NaN
## 605.8554325-1606.8553762 0 NaN NaN NaN
## 1087.8554325-1606.8553762 0 NaN NaN NaN
## 1606.8554325-1606.8553762 0 NaN NaN NaN
## 1992.8554325-1606.8553762 0 NaN NaN NaN
## 2140.8554325-1606.8553762 0 NaN NaN NaN
## 2219.8554325-1606.8553762 0 NaN NaN NaN
## 2140.8553762-1992.8553762 0 NaN NaN NaN
## 2219.8553762-1992.8553762 0 NaN NaN NaN
## 437.8553879-1992.8553762 0 NaN NaN NaN
## 605.8553879-1992.8553762 0 NaN NaN NaN
## 1087.8553879-1992.8553762 0 NaN NaN NaN
## 1606.8553879-1992.8553762 0 NaN NaN NaN
## 1992.8553879-1992.8553762 0 NaN NaN NaN
## 2140.8553879-1992.8553762 0 NaN NaN NaN
## 2219.8553879-1992.8553762 0 NaN NaN NaN
## 437.8554325-1992.8553762 0 NaN NaN NaN
## 605.8554325-1992.8553762 0 NaN NaN NaN
## 1087.8554325-1992.8553762 0 NaN NaN NaN
## 1606.8554325-1992.8553762 0 NaN NaN NaN
## 1992.8554325-1992.8553762 0 NaN NaN NaN
## 2140.8554325-1992.8553762 0 NaN NaN NaN
## 2219.8554325-1992.8553762 0 NaN NaN NaN
## 2219.8553762-2140.8553762 0 NaN NaN NaN
## 437.8553879-2140.8553762 0 NaN NaN NaN
## 605.8553879-2140.8553762 0 NaN NaN NaN
## 1087.8553879-2140.8553762 0 NaN NaN NaN
## 1606.8553879-2140.8553762 0 NaN NaN NaN
## 1992.8553879-2140.8553762 0 NaN NaN NaN
## 2140.8553879-2140.8553762 0 NaN NaN NaN
## 2219.8553879-2140.8553762 0 NaN NaN NaN
## 437.8554325-2140.8553762 0 NaN NaN NaN
## 605.8554325-2140.8553762 0 NaN NaN NaN
## 1087.8554325-2140.8553762 0 NaN NaN NaN
## 1606.8554325-2140.8553762 0 NaN NaN NaN
## 1992.8554325-2140.8553762 0 NaN NaN NaN
## 2140.8554325-2140.8553762 0 NaN NaN NaN
## 2219.8554325-2140.8553762 0 NaN NaN NaN
## 437.8553879-2219.8553762 0 NaN NaN NaN
## 605.8553879-2219.8553762 0 NaN NaN NaN
## 1087.8553879-2219.8553762 0 NaN NaN NaN
## 1606.8553879-2219.8553762 0 NaN NaN NaN
## 1992.8553879-2219.8553762 0 NaN NaN NaN
## 2140.8553879-2219.8553762 0 NaN NaN NaN
## 2219.8553879-2219.8553762 0 NaN NaN NaN
## 437.8554325-2219.8553762 0 NaN NaN NaN
## 605.8554325-2219.8553762 0 NaN NaN NaN
## 1087.8554325-2219.8553762 0 NaN NaN NaN
## 1606.8554325-2219.8553762 0 NaN NaN NaN
## 1992.8554325-2219.8553762 0 NaN NaN NaN
## 2140.8554325-2219.8553762 0 NaN NaN NaN
## 2219.8554325-2219.8553762 0 NaN NaN NaN
## 605.8553879-437.8553879 0 NaN NaN NaN
## 1087.8553879-437.8553879 0 NaN NaN NaN
## 1606.8553879-437.8553879 0 NaN NaN NaN
## 1992.8553879-437.8553879 0 NaN NaN NaN
## 2140.8553879-437.8553879 0 NaN NaN NaN
## 2219.8553879-437.8553879 0 NaN NaN NaN
## 437.8554325-437.8553879 0 NaN NaN NaN
## 605.8554325-437.8553879 0 NaN NaN NaN
## 1087.8554325-437.8553879 0 NaN NaN NaN
## 1606.8554325-437.8553879 0 NaN NaN NaN
## 1992.8554325-437.8553879 0 NaN NaN NaN
## 2140.8554325-437.8553879 0 NaN NaN NaN
## 2219.8554325-437.8553879 0 NaN NaN NaN
## 1087.8553879-605.8553879 0 NaN NaN NaN
## 1606.8553879-605.8553879 0 NaN NaN NaN
## 1992.8553879-605.8553879 0 NaN NaN NaN
## 2140.8553879-605.8553879 0 NaN NaN NaN
## 2219.8553879-605.8553879 0 NaN NaN NaN
## 437.8554325-605.8553879 0 NaN NaN NaN
## 605.8554325-605.8553879 0 NaN NaN NaN
## 1087.8554325-605.8553879 0 NaN NaN NaN
## 1606.8554325-605.8553879 0 NaN NaN NaN
## 1992.8554325-605.8553879 0 NaN NaN NaN
## 2140.8554325-605.8553879 0 NaN NaN NaN
## 2219.8554325-605.8553879 0 NaN NaN NaN
## 1606.8553879-1087.8553879 0 NaN NaN NaN
## 1992.8553879-1087.8553879 0 NaN NaN NaN
## 2140.8553879-1087.8553879 0 NaN NaN NaN
## 2219.8553879-1087.8553879 0 NaN NaN NaN
## 437.8554325-1087.8553879 0 NaN NaN NaN
## 605.8554325-1087.8553879 0 NaN NaN NaN
## 1087.8554325-1087.8553879 0 NaN NaN NaN
## 1606.8554325-1087.8553879 0 NaN NaN NaN
## 1992.8554325-1087.8553879 0 NaN NaN NaN
## 2140.8554325-1087.8553879 0 NaN NaN NaN
## 2219.8554325-1087.8553879 0 NaN NaN NaN
## 1992.8553879-1606.8553879 0 NaN NaN NaN
## 2140.8553879-1606.8553879 0 NaN NaN NaN
## 2219.8553879-1606.8553879 0 NaN NaN NaN
## 437.8554325-1606.8553879 0 NaN NaN NaN
## 605.8554325-1606.8553879 0 NaN NaN NaN
## 1087.8554325-1606.8553879 0 NaN NaN NaN
## 1606.8554325-1606.8553879 0 NaN NaN NaN
## 1992.8554325-1606.8553879 0 NaN NaN NaN
## 2140.8554325-1606.8553879 0 NaN NaN NaN
## 2219.8554325-1606.8553879 0 NaN NaN NaN
## 2140.8553879-1992.8553879 0 NaN NaN NaN
## 2219.8553879-1992.8553879 0 NaN NaN NaN
## 437.8554325-1992.8553879 0 NaN NaN NaN
## 605.8554325-1992.8553879 0 NaN NaN NaN
## 1087.8554325-1992.8553879 0 NaN NaN NaN
## 1606.8554325-1992.8553879 0 NaN NaN NaN
## 1992.8554325-1992.8553879 0 NaN NaN NaN
## 2140.8554325-1992.8553879 0 NaN NaN NaN
## 2219.8554325-1992.8553879 0 NaN NaN NaN
## 2219.8553879-2140.8553879 0 NaN NaN NaN
## 437.8554325-2140.8553879 0 NaN NaN NaN
## 605.8554325-2140.8553879 0 NaN NaN NaN
## 1087.8554325-2140.8553879 0 NaN NaN NaN
## 1606.8554325-2140.8553879 0 NaN NaN NaN
## 1992.8554325-2140.8553879 0 NaN NaN NaN
## 2140.8554325-2140.8553879 0 NaN NaN NaN
## 2219.8554325-2140.8553879 0 NaN NaN NaN
## 437.8554325-2219.8553879 0 NaN NaN NaN
## 605.8554325-2219.8553879 0 NaN NaN NaN
## 1087.8554325-2219.8553879 0 NaN NaN NaN
## 1606.8554325-2219.8553879 0 NaN NaN NaN
## 1992.8554325-2219.8553879 0 NaN NaN NaN
## 2140.8554325-2219.8553879 0 NaN NaN NaN
## 2219.8554325-2219.8553879 0 NaN NaN NaN
## 605.8554325-437.8554325 0 NaN NaN NaN
## 1087.8554325-437.8554325 0 NaN NaN NaN
## 1606.8554325-437.8554325 0 NaN NaN NaN
## 1992.8554325-437.8554325 0 NaN NaN NaN
## 2140.8554325-437.8554325 0 NaN NaN NaN
## 2219.8554325-437.8554325 0 NaN NaN NaN
## 1087.8554325-605.8554325 0 NaN NaN NaN
## 1606.8554325-605.8554325 0 NaN NaN NaN
## 1992.8554325-605.8554325 0 NaN NaN NaN
## 2140.8554325-605.8554325 0 NaN NaN NaN
## 2219.8554325-605.8554325 0 NaN NaN NaN
## 1606.8554325-1087.8554325 0 NaN NaN NaN
## 1992.8554325-1087.8554325 0 NaN NaN NaN
## 2140.8554325-1087.8554325 0 NaN NaN NaN
## 2219.8554325-1087.8554325 0 NaN NaN NaN
## 1992.8554325-1606.8554325 0 NaN NaN NaN
## 2140.8554325-1606.8554325 0 NaN NaN NaN
## 2219.8554325-1606.8554325 0 NaN NaN NaN
## 2140.8554325-1992.8554325 0 NaN NaN NaN
## 2219.8554325-1992.8554325 0 NaN NaN NaN
## 2219.8554325-2140.8554325 0 NaN NaN NaN
Question: Do growing degree days significantly influence the community composition (beta diversity) within Betula?
# Filter data for Betula_populifolia
betula_data <- asv_scaled_noPlants_Phen_filt_LMM[asv_scaled_noPlants_Phen_filt_LMM$Species ==
"Betula_populifolia", ]
# Perform PERMANOVA for Betula_populifolia
permanova_betula_beta <- adonis2(dist.mat_betula ~ GDD_5C * Plant_ID, data = betula_data,
permutations = 10000)
# Print PERMANOVA results for Betula_populifolia
print(permanova_betula_beta)
## Permutation test for adonis under reduced model
## Permutation: free
## Number of permutations: 10000
##
## adonis2(formula = dist.mat_betula ~ GDD_5C * Plant_ID, data = betula_data, permutations = 10000)
## Df SumOfSqs R2 F Pr(>F)
## Model 9 4.6036 0.37938 1.698 2e-04 ***
## Residual 25 7.5310 0.62062
## Total 34 12.1346 1.00000
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# NOTE: I can't seem to get pairwise PERMANOVAs to work...
# Current Error:
# Error in qr.fitted(qrhs, G) : 'qr' and 'y' must have the same number of rows
library(vegan)
library(pairwiseAdonis)
## Loading required package: cluster
library(dplyr)
# pairwise permanova
pairwise_perm_betula_beta <- pairwise.adonis2(dist.mat_betula ~ GDD_5C * Plant_ID,
data = betula_data, permutations = 10000)
pairwise_perm_betula_beta
## $parent_call
## [1] "dist.mat_betula ~ GDD_5C * Plant_ID , strata = Null , permutations 999"
##
## $`1087_vs_437`
## Df SumOfSqs R2 F Pr(>F)
## Model 9 3.2393 1
## Residual 0 0.0000 0
## Total 9 3.2393 1
##
## $`1087_vs_1606`
## Df SumOfSqs R2 F Pr(>F)
## Model 9 2.8182 1
## Residual 0 0.0000 0
## Total 9 2.8182 1
##
## $`1087_vs_605`
## Df SumOfSqs R2 F Pr(>F)
## Model 9 2.4693 1
## Residual 0 0.0000 0
## Total 9 2.4693 1
##
## $`1087_vs_2219`
## Df SumOfSqs R2 F Pr(>F)
## Model 9 3.1525 1
## Residual 0 0.0000 0
## Total 9 3.1525 1
##
## $`1087_vs_2140`
## Df SumOfSqs R2 F Pr(>F)
## Model 9 3.3348 1
## Residual 0 0.0000 0
## Total 9 3.3348 1
##
## $`1087_vs_1992`
## Df SumOfSqs R2 F Pr(>F)
## Model 9 3.1073 1
## Residual 0 0.0000 0
## Total 9 3.1073 1
##
## $`437_vs_1606`
## Df SumOfSqs R2 F Pr(>F)
## Model 9 3.4238 1
## Residual 0 0.0000 0
## Total 9 3.4238 1
##
## $`437_vs_605`
## Df SumOfSqs R2 F Pr(>F)
## Model 9 3.0036 1
## Residual 0 0.0000 0
## Total 9 3.0036 1
##
## $`437_vs_2219`
## Df SumOfSqs R2 F Pr(>F)
## Model 9 3.4619 1
## Residual 0 0.0000 0
## Total 9 3.4619 1
##
## $`437_vs_2140`
## Df SumOfSqs R2 F Pr(>F)
## Model 9 3.7153 1
## Residual 0 0.0000 0
## Total 9 3.7153 1
##
## $`437_vs_1992`
## Df SumOfSqs R2 F Pr(>F)
## Model 9 3.5385 1
## Residual 0 0.0000 0
## Total 9 3.5385 1
##
## $`1606_vs_605`
## Df SumOfSqs R2 F Pr(>F)
## Model 9 2.6592 1
## Residual 0 0.0000 0
## Total 9 2.6592 1
##
## $`1606_vs_2219`
## Df SumOfSqs R2 F Pr(>F)
## Model 9 2.8096 1
## Residual 0 0.0000 0
## Total 9 2.8096 1
##
## $`1606_vs_2140`
## Df SumOfSqs R2 F Pr(>F)
## Model 9 3.0644 1
## Residual 0 0.0000 0
## Total 9 3.0644 1
##
## $`1606_vs_1992`
## Df SumOfSqs R2 F Pr(>F)
## Model 9 2.9083 1
## Residual 0 0.0000 0
## Total 9 2.9083 1
##
## $`605_vs_2219`
## Df SumOfSqs R2 F Pr(>F)
## Model 9 3.115 1
## Residual 0 0.000 0
## Total 9 3.115 1
##
## $`605_vs_2140`
## Df SumOfSqs R2 F Pr(>F)
## Model 9 3.3002 1
## Residual 0 0.0000 0
## Total 9 3.3002 1
##
## $`605_vs_1992`
## Df SumOfSqs R2 F Pr(>F)
## Model 9 3.0665 1
## Residual 0 0.0000 0
## Total 9 3.0665 1
##
## $`2219_vs_2140`
## Df SumOfSqs R2 F Pr(>F)
## Model 9 2.5947 1
## Residual 0 0.0000 0
## Total 9 2.5947 1
##
## $`2219_vs_1992`
## Df SumOfSqs R2 F Pr(>F)
## Model 9 2.5323 1
## Residual 0 0.0000 0
## Total 9 2.5323 1
##
## $`2140_vs_1992`
## Df SumOfSqs R2 F Pr(>F)
## Model 9 2.9494 1
## Residual 0 0.0000 0
## Total 9 2.9494 1
##
## attr(,"class")
## [1] "pwadstrata" "list"
# Spearman correlation between Axis 1 and GDD_5C
cor_axis1_gdd_spearman_bet <- cor(pcoa.table_betula$Axis.1, betula_data$GDD_5C, method = "spearman")
# Spearman correlation between Axis 2 and GDD_5C
cor_axis2_gdd_spearman_bet <- cor(pcoa.table_betula$Axis.2, betula_data$GDD_5C, method = "spearman")
# Spearman correlation between Axis 2 and GDD_5C
cor_axis3_gdd_spearman_bet <- cor(pcoa.table_betula$Axis.3, betula_data$GDD_5C, method = "spearman")
# Print results
cat("Spearman correlation between Axis 1 and GDD_5C:", cor_axis1_gdd_spearman_bet,
"\n")
## Spearman correlation between Axis 1 and GDD_5C: -0.7157352
cat("Spearman correlation between Axis 2 and GDD_5C:", cor_axis2_gdd_spearman_bet,
"\n")
## Spearman correlation between Axis 2 and GDD_5C: 0.2715833
cat("Spearman correlation between Axis 3 and GDD_5C:", cor_axis2_gdd_spearman_bet,
"\n")
## Spearman correlation between Axis 3 and GDD_5C: 0.2715833
# Spearman correlation test for Axis 1
cor_test_axis1_spearman_bet <- cor.test(pcoa.table_betula$Axis.1, betula_data$GDD_5C,
method = "spearman")
## Warning in cor.test.default(pcoa.table_betula$Axis.1, betula_data$GDD_5C, :
## Cannot compute exact p-value with ties
# Spearman correlation test for Axis 2
cor_test_axis2_spearman_bet <- cor.test(pcoa.table_betula$Axis.2, betula_data$GDD_5C,
method = "spearman")
## Warning in cor.test.default(pcoa.table_betula$Axis.2, betula_data$GDD_5C, :
## Cannot compute exact p-value with ties
# Spearman correlation test for Axis 3
cor_test_axis3_spearman_bet <- cor.test(pcoa.table_betula$Axis.3, betula_data$GDD_5C,
method = "spearman")
## Warning in cor.test.default(pcoa.table_betula$Axis.3, betula_data$GDD_5C, :
## Cannot compute exact p-value with ties
# Print test results
print(cor_test_axis1_spearman_bet)
##
## Spearman's rank correlation rho
##
## data: pcoa.table_betula$Axis.1 and betula_data$GDD_5C
## S = 12250, p-value = 1.344e-06
## alternative hypothesis: true rho is not equal to 0
## sample estimates:
## rho
## -0.7157352
print(cor_test_axis2_spearman_bet)
##
## Spearman's rank correlation rho
##
## data: pcoa.table_betula$Axis.2 and betula_data$GDD_5C
## S = 5200.9, p-value = 0.1145
## alternative hypothesis: true rho is not equal to 0
## sample estimates:
## rho
## 0.2715833
print(cor_test_axis3_spearman_bet)
##
## Spearman's rank correlation rho
##
## data: pcoa.table_betula$Axis.3 and betula_data$GDD_5C
## S = 8473.1, p-value = 0.2828
## alternative hypothesis: true rho is not equal to 0
## sample estimates:
## rho
## -0.1867135
# Filter data for Populus_tremuloides
populus_data <- asv_scaled_noPlants_Phen_filt_LMM[asv_scaled_noPlants_Phen_filt_LMM$Species ==
"Populus_tremuloides", ]
# Calculate the multidispersion within data (Calculating significance of
# `Species`)
phen.disper.populus.gdd = betadisper(dist.mat_populus, populus_data$GDD_5C, type = "centroid")
phen.disper.populus.gdd
##
## Homogeneity of multivariate dispersions
##
## Call: betadisper(d = dist.mat_populus, group = populus_data$GDD_5C,
## type = "centroid")
##
## No. of Positive Eigenvalues: 35
## No. of Negative Eigenvalues: 0
##
## Average distance to centroid:
## 437 605 1087 1606 1992 2140 2219
## 0.5781 0.5865 0.5906 0.6033 0.5812 0.4905 0.5833
##
## Eigenvalues for PCoA axes:
## (Showing 8 of 35 eigenvalues)
## PCoA1 PCoA2 PCoA3 PCoA4 PCoA5 PCoA6 PCoA7 PCoA8
## 1.1318 0.8944 0.7291 0.6760 0.6355 0.6087 0.5831 0.5620
summary(phen.disper.populus.gdd)
## Length Class Mode
## eig 35 -none- numeric
## vectors 1260 -none- numeric
## distances 36 -none- numeric
## group 36 factor numeric
## centroids 245 -none- numeric
## group.distances 7 -none- numeric
## call 4 -none- call
permutest(phen.disper.populus.gdd, permutations = 10000)
##
## Permutation test for homogeneity of multivariate dispersions
## Permutation: free
## Number of permutations: 10000
##
## Response: Distances
## Df Sum Sq Mean Sq F N.Perm Pr(>F)
## Groups 6 0.042384 0.0070641 4.0047 10000 0.0043 **
## Residuals 29 0.051154 0.0017639
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
anova(phen.disper.populus.gdd)
## Analysis of Variance Table
##
## Response: Distances
## Df Sum Sq Mean Sq F value Pr(>F)
## Groups 6 0.042384 0.0070641 4.0047 0.00485 **
## Residuals 29 0.051154 0.0017639
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
plot(phen.disper.populus.gdd)
# Save as PNG
png("populus_disper_gdd_pcoa.png", width = 7, height = 4.85, units = "in", res = 600)
plot(phen.disper.populus.gdd)
dev.off()
## png
## 2
boxplot(phen.disper.populus.gdd, xlab = "Growing Degree Days (5°C)")
# Save as PNG
png("populus_disper_gdd_boxplot.png", width = 7, height = 4.85, units = "in", res = 600)
boxplot(phen.disper.populus.gdd, xlab = "Growing Degree Days (5°C)")
dev.off()
## png
## 2
TukeyHSD(phen.disper.populus.gdd) #Calculate pairwise difference
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = distances ~ group, data = df)
##
## $group
## diff lwr upr p adj
## 605-437 0.008374851 -0.075672344 0.092422047 0.9999056
## 1087-437 0.012500363 -0.067968700 0.092969426 0.9987830
## 1606-437 0.025248951 -0.058798245 0.109296146 0.9605188
## 1992-437 0.003133571 -0.080913624 0.087180767 0.9999997
## 2140-437 -0.087611174 -0.171658369 -0.003563979 0.0367446
## 2219-437 0.005181482 -0.078865713 0.089228677 0.9999944
## 1087-605 0.004125511 -0.076343552 0.084594574 0.9999981
## 1606-605 0.016874099 -0.067173096 0.100921294 0.9949723
## 1992-605 -0.005241280 -0.089288475 0.078805915 0.9999941
## 2140-605 -0.095986025 -0.180033221 -0.011938830 0.0172685
## 2219-605 -0.003193369 -0.087240565 0.080853826 0.9999997
## 1606-1087 0.012748588 -0.067720475 0.093217651 0.9986405
## 1992-1087 -0.009366791 -0.089835854 0.071102272 0.9997666
## 2140-1087 -0.100111537 -0.180580600 -0.019642474 0.0076828
## 2219-1087 -0.007318881 -0.087787944 0.073150183 0.9999447
## 1992-1606 -0.022115379 -0.106162574 0.061931816 0.9793372
## 2140-1606 -0.112860125 -0.196907320 -0.028812929 0.0034193
## 2219-1606 -0.020067469 -0.104114664 0.063979727 0.9874091
## 2140-1992 -0.090744745 -0.174791941 -0.006697550 0.0278335
## 2219-1992 0.002047911 -0.081999285 0.086095106 1.0000000
## 2219-2140 0.092792656 0.008745461 0.176839851 0.0231392
plot(TukeyHSD(phen.disper.populus.gdd))
# Calculate the multidispersion within data (Calculating significance of
# `Species`)
phen.disper.populus.plantid = betadisper(dist.mat_populus, populus_data$Plant_ID,
type = "centroid")
phen.disper.populus.plantid
##
## Homogeneity of multivariate dispersions
##
## Call: betadisper(d = dist.mat_populus, group = populus_data$Plant_ID,
## type = "centroid")
##
## No. of Positive Eigenvalues: 35
## No. of Negative Eigenvalues: 0
##
## Average distance to centroid:
## 8987795 8987955 8988752 8988899 9340742
## 0.6162 0.5956 0.6197 0.6080 0.6117
##
## Eigenvalues for PCoA axes:
## (Showing 8 of 35 eigenvalues)
## PCoA1 PCoA2 PCoA3 PCoA4 PCoA5 PCoA6 PCoA7 PCoA8
## 1.1318 0.8944 0.7291 0.6760 0.6355 0.6087 0.5831 0.5620
summary(phen.disper.populus.plantid)
## Length Class Mode
## eig 35 -none- numeric
## vectors 1260 -none- numeric
## distances 36 -none- numeric
## group 36 factor numeric
## centroids 175 -none- numeric
## group.distances 5 -none- numeric
## call 4 -none- call
# NOTE: The betadisper function calculates the multivariate dispersion
# (variability) within each group of the categorical variable (Plant_ID).
permutest(phen.disper.populus.plantid, permutations = 10000)
##
## Permutation test for homogeneity of multivariate dispersions
## Permutation: free
## Number of permutations: 10000
##
## Response: Distances
## Df Sum Sq Mean Sq F N.Perm Pr(>F)
## Groups 4 0.002471 0.00061765 0.5815 10000 0.6739
## Residuals 31 0.032925 0.00106208
# NOTE:The permutest function performs a permutation test to assess the
# significance of the F-statistic from the betadisper analysis. The results
# include the number of permutations (N.Perm) performed and the p-value
# (Pr(>F)) associated with the permutation test. In this case, the p-value is
# 0.691, indicating that the F-value is not significant.
anova(phen.disper.populus.plantid)
## Analysis of Variance Table
##
## Response: Distances
## Df Sum Sq Mean Sq F value Pr(>F)
## Groups 4 0.002471 0.00061765 0.5815 0.6783
## Residuals 31 0.032925 0.00106208
# The anova function provides an ANOVA-like analysis of the dispersion values
# among the groups. Groups F: The F-statistic for testing the null hypothesis
# of equal dispersion among the groups. The F-value is 0.5815. Groups Pr(>F):
# The p-value associated with the F-statistic. In this case, the p-value is
# 0.6783, indicating that the differences in dispersion among groups are not
# statistically significant.
plot(phen.disper.populus.plantid)
# Save as PNG
png("populus_disper_plantid_pcoa.png", width = 7, height = 4.85, units = "in", res = 600)
plot(phen.disper.populus.plantid)
dev.off()
boxplot(phen.disper.populus.plantid, xlab = "Plant ID")
# Save as PNG
png("populus_disper_plantid_boxplot.png", width = 7, height = 4.85, units = "in",
res = 600)
boxplot(phen.disper.populus.plantid, xlab = "Plant ID")
dev.off()
TukeyHSD(phen.disper.populus.plantid) #Calculate pairwise difference
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = distances ~ group, data = df)
##
## $group
## diff lwr upr p adj
## 8987955-8987795 -0.020676606 -0.06950260 0.02814939 0.7366185
## 8988752-8987795 0.003443577 -0.04538242 0.05226957 0.9995900
## 8988899-8987795 -0.008293537 -0.05711953 0.04053246 0.9875655
## 9340742-8987795 -0.004560764 -0.05338676 0.04426523 0.9987592
## 8988752-8987955 0.024120182 -0.02630709 0.07454745 0.6417109
## 8988899-8987955 0.012383068 -0.03804420 0.06281034 0.9524450
## 9340742-8987955 0.016115842 -0.03431143 0.06654311 0.8849761
## 8988899-8988752 -0.011737114 -0.06216438 0.03869015 0.9606235
## 9340742-8988752 -0.008004340 -0.05843161 0.04242293 0.9903674
## 9340742-8988899 0.003732773 -0.04669450 0.05416004 0.9995036
plot(TukeyHSD(phen.disper.populus.plantid))
# Influence taxonomic composition on betadiveristy by GDDs
phen.populus.gdd.adonis2 <- adonis2(dist.mat_populus ~ populus_data$GDD_5C, perm = 10000) #Calculate influence of treatment using community matrix
phen.populus.gdd.adonis2
## Permutation test for adonis under reduced model
## Permutation: free
## Number of permutations: 10000
##
## adonis2(formula = dist.mat_populus ~ populus_data$GDD_5C, permutations = 10000)
## Df SumOfSqs R2 F Pr(>F)
## Model 1 0.5559 0.03702 1.3069 0.015 *
## Residual 34 14.4618 0.96298
## Total 35 15.0177 1.00000
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Influence taxonomic composition on betadiveristy by Plant_ID
phen.populus.plantid.adonis2 <- adonis2(dist.mat_populus ~ populus_data$Plant_ID,
perm = 10000) #Calculate influence of treatment using community matrix
phen.populus.plantid.adonis2
## Permutation test for adonis under reduced model
## Permutation: free
## Number of permutations: 10000
##
## adonis2(formula = dist.mat_populus ~ populus_data$Plant_ID, permutations = 10000)
## Df SumOfSqs R2 F Pr(>F)
## Model 4 1.5693 0.10449 0.9043 0.9614
## Residual 31 13.4485 0.89551
## Total 35 15.0177 1.00000
# 1. Multidispersion Analysis for Interaction (Species & GDDs):
# Calculate multidispersion considering interaction
phen.disper.populus.interact <- betadisper(dist.mat_populus, interaction(populus_data$GDD_5C,
populus_data$Plant_ID), type = "centroid")
# 2. Permutation Test for Interaction:
permutest(phen.disper.populus.interact, permutations = 10000)
## Warning in anova.lm(lm(Distances ~ Groups, data = model.dat)): ANOVA F-tests on
## an essentially perfect fit are unreliable
## Warning in summary.lm(mod): essentially perfect fit: summary may be unreliable
##
## Permutation test for homogeneity of multivariate dispersions
## Permutation: free
## Number of permutations: 10000
##
## Response: Distances
## Df Sum Sq Mean Sq F N.Perm Pr(>F)
## Groups 34 0.41692 0.012262 2.1278e+60 10000 0.006199 **
## Residuals 1 0.00000 0.000000
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# 3. ANOVA-Like Analysis for Interaction:
anova(phen.disper.populus.interact)
## Warning in anova.lm(lm(Distances ~ Groups, data = model.dat)): ANOVA F-tests on
## an essentially perfect fit are unreliable
## Analysis of Variance Table
##
## Response: Distances
## Df Sum Sq Mean Sq F value Pr(>F)
## Groups 34 0.41692 0.012262 2.1278e+60 < 2.2e-16 ***
## Residuals 1 0.00000 0.000000
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
plot(phen.disper.populus.interact)
## Warning in plot.xy(xy.coords(x, y), type = type, ...): unimplemented pch value
## '26'
## Warning in plot.xy(xy.coords(x, y), type = type, ...): unimplemented pch value
## '31'
## Warning in plot.xy(xy.coords(x, y), type = type, ...): unimplemented pch value
## '29'
## Warning in plot.xy(xy.coords(x, y), type = type, ...): unimplemented pch value
## '30'
## Warning in plot.xy(xy.coords(x, y), type = type, ...): unimplemented pch value
## '27'
## Warning in plot.xy(xy.coords(x, y), type = type, ...): unimplemented pch value
## '28'
# Post-hoc Pairwise Comparisons for Interaction
pairwise_dispersion_populus_interact <- TukeyHSD(phen.disper.populus.interact)
## Warning in qtukey(conf.level, length(means), x$df.residual): NaNs produced
## Warning in ptukey(abs(est), length(means), x$df.residual, lower.tail = FALSE):
## NaNs produced
head(pairwise_dispersion_populus_interact)
## $group
## diff lwr upr p adj
## 605.8987795-437.8987795 -1.075529e-16 NaN NaN NaN
## 1087.8987795-437.8987795 4.698113e-01 NaN NaN NaN
## 1606.8987795-437.8987795 -6.938894e-18 NaN NaN NaN
## 1992.8987795-437.8987795 -6.938894e-18 NaN NaN NaN
## 2140.8987795-437.8987795 -6.938894e-18 NaN NaN NaN
## 2219.8987795-437.8987795 -6.938894e-18 NaN NaN NaN
## 437.8987955-437.8987795 -6.938894e-18 NaN NaN NaN
## 605.8987955-437.8987795 -6.938894e-18 NaN NaN NaN
## 1087.8987955-437.8987795 -6.938894e-18 NaN NaN NaN
## 1606.8987955-437.8987795 -6.938894e-18 NaN NaN NaN
## 1992.8987955-437.8987795 -6.938894e-18 NaN NaN NaN
## 2140.8987955-437.8987795 -6.938894e-18 NaN NaN NaN
## 2219.8987955-437.8987795 -6.938894e-18 NaN NaN NaN
## 437.8988752-437.8987795 -6.938894e-18 NaN NaN NaN
## 605.8988752-437.8987795 -6.938894e-18 NaN NaN NaN
## 1087.8988752-437.8987795 -6.938894e-18 NaN NaN NaN
## 1606.8988752-437.8987795 -6.938894e-18 NaN NaN NaN
## 1992.8988752-437.8987795 -6.938894e-18 NaN NaN NaN
## 2140.8988752-437.8987795 -6.938894e-18 NaN NaN NaN
## 2219.8988752-437.8987795 -6.938894e-18 NaN NaN NaN
## 437.8988899-437.8987795 -6.938894e-18 NaN NaN NaN
## 605.8988899-437.8987795 -3.469447e-18 NaN NaN NaN
## 1087.8988899-437.8987795 -3.469447e-18 NaN NaN NaN
## 1606.8988899-437.8987795 -3.469447e-18 NaN NaN NaN
## 1992.8988899-437.8987795 -1.040834e-17 NaN NaN NaN
## 2140.8988899-437.8987795 -3.469447e-18 NaN NaN NaN
## 2219.8988899-437.8987795 0.000000e+00 NaN NaN 1
## 437.9340742-437.8987795 0.000000e+00 NaN NaN 1
## 605.9340742-437.8987795 0.000000e+00 NaN NaN 1
## 1087.9340742-437.8987795 -2.428613e-17 NaN NaN NaN
## 1606.9340742-437.8987795 0.000000e+00 NaN NaN 1
## 1992.9340742-437.8987795 0.000000e+00 NaN NaN 1
## 2140.9340742-437.8987795 0.000000e+00 NaN NaN 1
## 2219.9340742-437.8987795 0.000000e+00 NaN NaN 1
## 1087.8987795-605.8987795 4.698113e-01 NaN NaN NaN
## 1606.8987795-605.8987795 1.006140e-16 NaN NaN NaN
## 1992.8987795-605.8987795 1.006140e-16 NaN NaN NaN
## 2140.8987795-605.8987795 1.006140e-16 NaN NaN NaN
## 2219.8987795-605.8987795 1.006140e-16 NaN NaN NaN
## 437.8987955-605.8987795 1.006140e-16 NaN NaN NaN
## 605.8987955-605.8987795 1.006140e-16 NaN NaN NaN
## 1087.8987955-605.8987795 1.006140e-16 NaN NaN NaN
## 1606.8987955-605.8987795 1.006140e-16 NaN NaN NaN
## 1992.8987955-605.8987795 1.006140e-16 NaN NaN NaN
## 2140.8987955-605.8987795 1.006140e-16 NaN NaN NaN
## 2219.8987955-605.8987795 1.006140e-16 NaN NaN NaN
## 437.8988752-605.8987795 1.006140e-16 NaN NaN NaN
## 605.8988752-605.8987795 1.006140e-16 NaN NaN NaN
## 1087.8988752-605.8987795 1.006140e-16 NaN NaN NaN
## 1606.8988752-605.8987795 1.006140e-16 NaN NaN NaN
## 1992.8988752-605.8987795 1.006140e-16 NaN NaN NaN
## 2140.8988752-605.8987795 1.006140e-16 NaN NaN NaN
## 2219.8988752-605.8987795 1.006140e-16 NaN NaN NaN
## 437.8988899-605.8987795 1.006140e-16 NaN NaN NaN
## 605.8988899-605.8987795 1.040834e-16 NaN NaN NaN
## 1087.8988899-605.8987795 1.040834e-16 NaN NaN NaN
## 1606.8988899-605.8987795 1.040834e-16 NaN NaN NaN
## 1992.8988899-605.8987795 9.714451e-17 NaN NaN NaN
## 2140.8988899-605.8987795 1.040834e-16 NaN NaN NaN
## 2219.8988899-605.8987795 1.075529e-16 NaN NaN NaN
## 437.9340742-605.8987795 1.075529e-16 NaN NaN NaN
## 605.9340742-605.8987795 1.075529e-16 NaN NaN NaN
## 1087.9340742-605.8987795 8.326673e-17 NaN NaN NaN
## 1606.9340742-605.8987795 1.075529e-16 NaN NaN NaN
## 1992.9340742-605.8987795 1.075529e-16 NaN NaN NaN
## 2140.9340742-605.8987795 1.075529e-16 NaN NaN NaN
## 2219.9340742-605.8987795 1.075529e-16 NaN NaN NaN
## 1606.8987795-1087.8987795 -4.698113e-01 NaN NaN NaN
## 1992.8987795-1087.8987795 -4.698113e-01 NaN NaN NaN
## 2140.8987795-1087.8987795 -4.698113e-01 NaN NaN NaN
## 2219.8987795-1087.8987795 -4.698113e-01 NaN NaN NaN
## 437.8987955-1087.8987795 -4.698113e-01 NaN NaN NaN
## 605.8987955-1087.8987795 -4.698113e-01 NaN NaN NaN
## 1087.8987955-1087.8987795 -4.698113e-01 NaN NaN NaN
## 1606.8987955-1087.8987795 -4.698113e-01 NaN NaN NaN
## 1992.8987955-1087.8987795 -4.698113e-01 NaN NaN NaN
## 2140.8987955-1087.8987795 -4.698113e-01 NaN NaN NaN
## 2219.8987955-1087.8987795 -4.698113e-01 NaN NaN NaN
## 437.8988752-1087.8987795 -4.698113e-01 NaN NaN NaN
## 605.8988752-1087.8987795 -4.698113e-01 NaN NaN NaN
## 1087.8988752-1087.8987795 -4.698113e-01 NaN NaN NaN
## 1606.8988752-1087.8987795 -4.698113e-01 NaN NaN NaN
## 1992.8988752-1087.8987795 -4.698113e-01 NaN NaN NaN
## 2140.8988752-1087.8987795 -4.698113e-01 NaN NaN NaN
## 2219.8988752-1087.8987795 -4.698113e-01 NaN NaN NaN
## 437.8988899-1087.8987795 -4.698113e-01 NaN NaN NaN
## 605.8988899-1087.8987795 -4.698113e-01 NaN NaN NaN
## 1087.8988899-1087.8987795 -4.698113e-01 NaN NaN NaN
## 1606.8988899-1087.8987795 -4.698113e-01 NaN NaN NaN
## 1992.8988899-1087.8987795 -4.698113e-01 NaN NaN NaN
## 2140.8988899-1087.8987795 -4.698113e-01 NaN NaN NaN
## 2219.8988899-1087.8987795 -4.698113e-01 NaN NaN NaN
## 437.9340742-1087.8987795 -4.698113e-01 NaN NaN NaN
## 605.9340742-1087.8987795 -4.698113e-01 NaN NaN NaN
## 1087.9340742-1087.8987795 -4.698113e-01 NaN NaN NaN
## 1606.9340742-1087.8987795 -4.698113e-01 NaN NaN NaN
## 1992.9340742-1087.8987795 -4.698113e-01 NaN NaN NaN
## 2140.9340742-1087.8987795 -4.698113e-01 NaN NaN NaN
## 2219.9340742-1087.8987795 -4.698113e-01 NaN NaN NaN
## 1992.8987795-1606.8987795 0.000000e+00 NaN NaN 1
## 2140.8987795-1606.8987795 0.000000e+00 NaN NaN 1
## 2219.8987795-1606.8987795 0.000000e+00 NaN NaN 1
## 437.8987955-1606.8987795 0.000000e+00 NaN NaN 1
## 605.8987955-1606.8987795 0.000000e+00 NaN NaN 1
## 1087.8987955-1606.8987795 0.000000e+00 NaN NaN 1
## 1606.8987955-1606.8987795 0.000000e+00 NaN NaN 1
## 1992.8987955-1606.8987795 0.000000e+00 NaN NaN 1
## 2140.8987955-1606.8987795 0.000000e+00 NaN NaN 1
## 2219.8987955-1606.8987795 0.000000e+00 NaN NaN 1
## 437.8988752-1606.8987795 0.000000e+00 NaN NaN 1
## 605.8988752-1606.8987795 0.000000e+00 NaN NaN 1
## 1087.8988752-1606.8987795 0.000000e+00 NaN NaN 1
## 1606.8988752-1606.8987795 0.000000e+00 NaN NaN 1
## 1992.8988752-1606.8987795 0.000000e+00 NaN NaN 1
## 2140.8988752-1606.8987795 0.000000e+00 NaN NaN 1
## 2219.8988752-1606.8987795 0.000000e+00 NaN NaN 1
## 437.8988899-1606.8987795 0.000000e+00 NaN NaN 1
## 605.8988899-1606.8987795 3.469447e-18 NaN NaN NaN
## 1087.8988899-1606.8987795 3.469447e-18 NaN NaN NaN
## 1606.8988899-1606.8987795 3.469447e-18 NaN NaN NaN
## 1992.8988899-1606.8987795 -3.469447e-18 NaN NaN NaN
## 2140.8988899-1606.8987795 3.469447e-18 NaN NaN NaN
## 2219.8988899-1606.8987795 6.938894e-18 NaN NaN NaN
## 437.9340742-1606.8987795 6.938894e-18 NaN NaN NaN
## 605.9340742-1606.8987795 6.938894e-18 NaN NaN NaN
## 1087.9340742-1606.8987795 -1.734723e-17 NaN NaN NaN
## 1606.9340742-1606.8987795 6.938894e-18 NaN NaN NaN
## 1992.9340742-1606.8987795 6.938894e-18 NaN NaN NaN
## 2140.9340742-1606.8987795 6.938894e-18 NaN NaN NaN
## 2219.9340742-1606.8987795 6.938894e-18 NaN NaN NaN
## 2140.8987795-1992.8987795 0.000000e+00 NaN NaN 1
## 2219.8987795-1992.8987795 0.000000e+00 NaN NaN 1
## 437.8987955-1992.8987795 0.000000e+00 NaN NaN 1
## 605.8987955-1992.8987795 0.000000e+00 NaN NaN 1
## 1087.8987955-1992.8987795 0.000000e+00 NaN NaN 1
## 1606.8987955-1992.8987795 0.000000e+00 NaN NaN 1
## 1992.8987955-1992.8987795 0.000000e+00 NaN NaN 1
## 2140.8987955-1992.8987795 0.000000e+00 NaN NaN 1
## 2219.8987955-1992.8987795 0.000000e+00 NaN NaN 1
## 437.8988752-1992.8987795 0.000000e+00 NaN NaN 1
## 605.8988752-1992.8987795 0.000000e+00 NaN NaN 1
## 1087.8988752-1992.8987795 0.000000e+00 NaN NaN 1
## 1606.8988752-1992.8987795 0.000000e+00 NaN NaN 1
## 1992.8988752-1992.8987795 0.000000e+00 NaN NaN 1
## 2140.8988752-1992.8987795 0.000000e+00 NaN NaN 1
## 2219.8988752-1992.8987795 0.000000e+00 NaN NaN 1
## 437.8988899-1992.8987795 0.000000e+00 NaN NaN 1
## 605.8988899-1992.8987795 3.469447e-18 NaN NaN NaN
## 1087.8988899-1992.8987795 3.469447e-18 NaN NaN NaN
## 1606.8988899-1992.8987795 3.469447e-18 NaN NaN NaN
## 1992.8988899-1992.8987795 -3.469447e-18 NaN NaN NaN
## 2140.8988899-1992.8987795 3.469447e-18 NaN NaN NaN
## 2219.8988899-1992.8987795 6.938894e-18 NaN NaN NaN
## 437.9340742-1992.8987795 6.938894e-18 NaN NaN NaN
## 605.9340742-1992.8987795 6.938894e-18 NaN NaN NaN
## 1087.9340742-1992.8987795 -1.734723e-17 NaN NaN NaN
## 1606.9340742-1992.8987795 6.938894e-18 NaN NaN NaN
## 1992.9340742-1992.8987795 6.938894e-18 NaN NaN NaN
## 2140.9340742-1992.8987795 6.938894e-18 NaN NaN NaN
## 2219.9340742-1992.8987795 6.938894e-18 NaN NaN NaN
## 2219.8987795-2140.8987795 0.000000e+00 NaN NaN 1
## 437.8987955-2140.8987795 0.000000e+00 NaN NaN 1
## 605.8987955-2140.8987795 0.000000e+00 NaN NaN 1
## 1087.8987955-2140.8987795 0.000000e+00 NaN NaN 1
## 1606.8987955-2140.8987795 0.000000e+00 NaN NaN 1
## 1992.8987955-2140.8987795 0.000000e+00 NaN NaN 1
## 2140.8987955-2140.8987795 0.000000e+00 NaN NaN 1
## 2219.8987955-2140.8987795 0.000000e+00 NaN NaN 1
## 437.8988752-2140.8987795 0.000000e+00 NaN NaN 1
## 605.8988752-2140.8987795 0.000000e+00 NaN NaN 1
## 1087.8988752-2140.8987795 0.000000e+00 NaN NaN 1
## 1606.8988752-2140.8987795 0.000000e+00 NaN NaN 1
## 1992.8988752-2140.8987795 0.000000e+00 NaN NaN 1
## 2140.8988752-2140.8987795 0.000000e+00 NaN NaN 1
## 2219.8988752-2140.8987795 0.000000e+00 NaN NaN 1
## 437.8988899-2140.8987795 0.000000e+00 NaN NaN 1
## 605.8988899-2140.8987795 3.469447e-18 NaN NaN NaN
## 1087.8988899-2140.8987795 3.469447e-18 NaN NaN NaN
## 1606.8988899-2140.8987795 3.469447e-18 NaN NaN NaN
## 1992.8988899-2140.8987795 -3.469447e-18 NaN NaN NaN
## 2140.8988899-2140.8987795 3.469447e-18 NaN NaN NaN
## 2219.8988899-2140.8987795 6.938894e-18 NaN NaN NaN
## 437.9340742-2140.8987795 6.938894e-18 NaN NaN NaN
## 605.9340742-2140.8987795 6.938894e-18 NaN NaN NaN
## 1087.9340742-2140.8987795 -1.734723e-17 NaN NaN NaN
## 1606.9340742-2140.8987795 6.938894e-18 NaN NaN NaN
## 1992.9340742-2140.8987795 6.938894e-18 NaN NaN NaN
## 2140.9340742-2140.8987795 6.938894e-18 NaN NaN NaN
## 2219.9340742-2140.8987795 6.938894e-18 NaN NaN NaN
## 437.8987955-2219.8987795 0.000000e+00 NaN NaN 1
## 605.8987955-2219.8987795 0.000000e+00 NaN NaN 1
## 1087.8987955-2219.8987795 0.000000e+00 NaN NaN 1
## 1606.8987955-2219.8987795 0.000000e+00 NaN NaN 1
## 1992.8987955-2219.8987795 0.000000e+00 NaN NaN 1
## 2140.8987955-2219.8987795 0.000000e+00 NaN NaN 1
## 2219.8987955-2219.8987795 0.000000e+00 NaN NaN 1
## 437.8988752-2219.8987795 0.000000e+00 NaN NaN 1
## 605.8988752-2219.8987795 0.000000e+00 NaN NaN 1
## 1087.8988752-2219.8987795 0.000000e+00 NaN NaN 1
## 1606.8988752-2219.8987795 0.000000e+00 NaN NaN 1
## 1992.8988752-2219.8987795 0.000000e+00 NaN NaN 1
## 2140.8988752-2219.8987795 0.000000e+00 NaN NaN 1
## 2219.8988752-2219.8987795 0.000000e+00 NaN NaN 1
## 437.8988899-2219.8987795 0.000000e+00 NaN NaN 1
## 605.8988899-2219.8987795 3.469447e-18 NaN NaN NaN
## 1087.8988899-2219.8987795 3.469447e-18 NaN NaN NaN
## 1606.8988899-2219.8987795 3.469447e-18 NaN NaN NaN
## 1992.8988899-2219.8987795 -3.469447e-18 NaN NaN NaN
## 2140.8988899-2219.8987795 3.469447e-18 NaN NaN NaN
## 2219.8988899-2219.8987795 6.938894e-18 NaN NaN NaN
## 437.9340742-2219.8987795 6.938894e-18 NaN NaN NaN
## 605.9340742-2219.8987795 6.938894e-18 NaN NaN NaN
## 1087.9340742-2219.8987795 -1.734723e-17 NaN NaN NaN
## 1606.9340742-2219.8987795 6.938894e-18 NaN NaN NaN
## 1992.9340742-2219.8987795 6.938894e-18 NaN NaN NaN
## 2140.9340742-2219.8987795 6.938894e-18 NaN NaN NaN
## 2219.9340742-2219.8987795 6.938894e-18 NaN NaN NaN
## 605.8987955-437.8987955 0.000000e+00 NaN NaN 1
## 1087.8987955-437.8987955 0.000000e+00 NaN NaN 1
## 1606.8987955-437.8987955 0.000000e+00 NaN NaN 1
## 1992.8987955-437.8987955 0.000000e+00 NaN NaN 1
## 2140.8987955-437.8987955 0.000000e+00 NaN NaN 1
## 2219.8987955-437.8987955 0.000000e+00 NaN NaN 1
## 437.8988752-437.8987955 0.000000e+00 NaN NaN 1
## 605.8988752-437.8987955 0.000000e+00 NaN NaN 1
## 1087.8988752-437.8987955 0.000000e+00 NaN NaN 1
## 1606.8988752-437.8987955 0.000000e+00 NaN NaN 1
## 1992.8988752-437.8987955 0.000000e+00 NaN NaN 1
## 2140.8988752-437.8987955 0.000000e+00 NaN NaN 1
## 2219.8988752-437.8987955 0.000000e+00 NaN NaN 1
## 437.8988899-437.8987955 0.000000e+00 NaN NaN 1
## 605.8988899-437.8987955 3.469447e-18 NaN NaN NaN
## 1087.8988899-437.8987955 3.469447e-18 NaN NaN NaN
## 1606.8988899-437.8987955 3.469447e-18 NaN NaN NaN
## 1992.8988899-437.8987955 -3.469447e-18 NaN NaN NaN
## 2140.8988899-437.8987955 3.469447e-18 NaN NaN NaN
## 2219.8988899-437.8987955 6.938894e-18 NaN NaN NaN
## 437.9340742-437.8987955 6.938894e-18 NaN NaN NaN
## 605.9340742-437.8987955 6.938894e-18 NaN NaN NaN
## 1087.9340742-437.8987955 -1.734723e-17 NaN NaN NaN
## 1606.9340742-437.8987955 6.938894e-18 NaN NaN NaN
## 1992.9340742-437.8987955 6.938894e-18 NaN NaN NaN
## 2140.9340742-437.8987955 6.938894e-18 NaN NaN NaN
## 2219.9340742-437.8987955 6.938894e-18 NaN NaN NaN
## 1087.8987955-605.8987955 0.000000e+00 NaN NaN 1
## 1606.8987955-605.8987955 0.000000e+00 NaN NaN 1
## 1992.8987955-605.8987955 0.000000e+00 NaN NaN 1
## 2140.8987955-605.8987955 0.000000e+00 NaN NaN 1
## 2219.8987955-605.8987955 0.000000e+00 NaN NaN 1
## 437.8988752-605.8987955 0.000000e+00 NaN NaN 1
## 605.8988752-605.8987955 0.000000e+00 NaN NaN 1
## 1087.8988752-605.8987955 0.000000e+00 NaN NaN 1
## 1606.8988752-605.8987955 0.000000e+00 NaN NaN 1
## 1992.8988752-605.8987955 0.000000e+00 NaN NaN 1
## 2140.8988752-605.8987955 0.000000e+00 NaN NaN 1
## 2219.8988752-605.8987955 0.000000e+00 NaN NaN 1
## 437.8988899-605.8987955 0.000000e+00 NaN NaN 1
## 605.8988899-605.8987955 3.469447e-18 NaN NaN NaN
## 1087.8988899-605.8987955 3.469447e-18 NaN NaN NaN
## 1606.8988899-605.8987955 3.469447e-18 NaN NaN NaN
## 1992.8988899-605.8987955 -3.469447e-18 NaN NaN NaN
## 2140.8988899-605.8987955 3.469447e-18 NaN NaN NaN
## 2219.8988899-605.8987955 6.938894e-18 NaN NaN NaN
## 437.9340742-605.8987955 6.938894e-18 NaN NaN NaN
## 605.9340742-605.8987955 6.938894e-18 NaN NaN NaN
## 1087.9340742-605.8987955 -1.734723e-17 NaN NaN NaN
## 1606.9340742-605.8987955 6.938894e-18 NaN NaN NaN
## 1992.9340742-605.8987955 6.938894e-18 NaN NaN NaN
## 2140.9340742-605.8987955 6.938894e-18 NaN NaN NaN
## 2219.9340742-605.8987955 6.938894e-18 NaN NaN NaN
## 1606.8987955-1087.8987955 0.000000e+00 NaN NaN 1
## 1992.8987955-1087.8987955 0.000000e+00 NaN NaN 1
## 2140.8987955-1087.8987955 0.000000e+00 NaN NaN 1
## 2219.8987955-1087.8987955 0.000000e+00 NaN NaN 1
## 437.8988752-1087.8987955 0.000000e+00 NaN NaN 1
## 605.8988752-1087.8987955 0.000000e+00 NaN NaN 1
## 1087.8988752-1087.8987955 0.000000e+00 NaN NaN 1
## 1606.8988752-1087.8987955 0.000000e+00 NaN NaN 1
## 1992.8988752-1087.8987955 0.000000e+00 NaN NaN 1
## 2140.8988752-1087.8987955 0.000000e+00 NaN NaN 1
## 2219.8988752-1087.8987955 0.000000e+00 NaN NaN 1
## 437.8988899-1087.8987955 0.000000e+00 NaN NaN 1
## 605.8988899-1087.8987955 3.469447e-18 NaN NaN NaN
## 1087.8988899-1087.8987955 3.469447e-18 NaN NaN NaN
## 1606.8988899-1087.8987955 3.469447e-18 NaN NaN NaN
## 1992.8988899-1087.8987955 -3.469447e-18 NaN NaN NaN
## 2140.8988899-1087.8987955 3.469447e-18 NaN NaN NaN
## 2219.8988899-1087.8987955 6.938894e-18 NaN NaN NaN
## 437.9340742-1087.8987955 6.938894e-18 NaN NaN NaN
## 605.9340742-1087.8987955 6.938894e-18 NaN NaN NaN
## 1087.9340742-1087.8987955 -1.734723e-17 NaN NaN NaN
## 1606.9340742-1087.8987955 6.938894e-18 NaN NaN NaN
## 1992.9340742-1087.8987955 6.938894e-18 NaN NaN NaN
## 2140.9340742-1087.8987955 6.938894e-18 NaN NaN NaN
## 2219.9340742-1087.8987955 6.938894e-18 NaN NaN NaN
## 1992.8987955-1606.8987955 0.000000e+00 NaN NaN 1
## 2140.8987955-1606.8987955 0.000000e+00 NaN NaN 1
## 2219.8987955-1606.8987955 0.000000e+00 NaN NaN 1
## 437.8988752-1606.8987955 0.000000e+00 NaN NaN 1
## 605.8988752-1606.8987955 0.000000e+00 NaN NaN 1
## 1087.8988752-1606.8987955 0.000000e+00 NaN NaN 1
## 1606.8988752-1606.8987955 0.000000e+00 NaN NaN 1
## 1992.8988752-1606.8987955 0.000000e+00 NaN NaN 1
## 2140.8988752-1606.8987955 0.000000e+00 NaN NaN 1
## 2219.8988752-1606.8987955 0.000000e+00 NaN NaN 1
## 437.8988899-1606.8987955 0.000000e+00 NaN NaN 1
## 605.8988899-1606.8987955 3.469447e-18 NaN NaN NaN
## 1087.8988899-1606.8987955 3.469447e-18 NaN NaN NaN
## 1606.8988899-1606.8987955 3.469447e-18 NaN NaN NaN
## 1992.8988899-1606.8987955 -3.469447e-18 NaN NaN NaN
## 2140.8988899-1606.8987955 3.469447e-18 NaN NaN NaN
## 2219.8988899-1606.8987955 6.938894e-18 NaN NaN NaN
## 437.9340742-1606.8987955 6.938894e-18 NaN NaN NaN
## 605.9340742-1606.8987955 6.938894e-18 NaN NaN NaN
## 1087.9340742-1606.8987955 -1.734723e-17 NaN NaN NaN
## 1606.9340742-1606.8987955 6.938894e-18 NaN NaN NaN
## 1992.9340742-1606.8987955 6.938894e-18 NaN NaN NaN
## 2140.9340742-1606.8987955 6.938894e-18 NaN NaN NaN
## 2219.9340742-1606.8987955 6.938894e-18 NaN NaN NaN
## 2140.8987955-1992.8987955 0.000000e+00 NaN NaN 1
## 2219.8987955-1992.8987955 0.000000e+00 NaN NaN 1
## 437.8988752-1992.8987955 0.000000e+00 NaN NaN 1
## 605.8988752-1992.8987955 0.000000e+00 NaN NaN 1
## 1087.8988752-1992.8987955 0.000000e+00 NaN NaN 1
## 1606.8988752-1992.8987955 0.000000e+00 NaN NaN 1
## 1992.8988752-1992.8987955 0.000000e+00 NaN NaN 1
## 2140.8988752-1992.8987955 0.000000e+00 NaN NaN 1
## 2219.8988752-1992.8987955 0.000000e+00 NaN NaN 1
## 437.8988899-1992.8987955 0.000000e+00 NaN NaN 1
## 605.8988899-1992.8987955 3.469447e-18 NaN NaN NaN
## 1087.8988899-1992.8987955 3.469447e-18 NaN NaN NaN
## 1606.8988899-1992.8987955 3.469447e-18 NaN NaN NaN
## 1992.8988899-1992.8987955 -3.469447e-18 NaN NaN NaN
## 2140.8988899-1992.8987955 3.469447e-18 NaN NaN NaN
## 2219.8988899-1992.8987955 6.938894e-18 NaN NaN NaN
## 437.9340742-1992.8987955 6.938894e-18 NaN NaN NaN
## 605.9340742-1992.8987955 6.938894e-18 NaN NaN NaN
## 1087.9340742-1992.8987955 -1.734723e-17 NaN NaN NaN
## 1606.9340742-1992.8987955 6.938894e-18 NaN NaN NaN
## 1992.9340742-1992.8987955 6.938894e-18 NaN NaN NaN
## 2140.9340742-1992.8987955 6.938894e-18 NaN NaN NaN
## 2219.9340742-1992.8987955 6.938894e-18 NaN NaN NaN
## 2219.8987955-2140.8987955 0.000000e+00 NaN NaN 1
## 437.8988752-2140.8987955 0.000000e+00 NaN NaN 1
## 605.8988752-2140.8987955 0.000000e+00 NaN NaN 1
## 1087.8988752-2140.8987955 0.000000e+00 NaN NaN 1
## 1606.8988752-2140.8987955 0.000000e+00 NaN NaN 1
## 1992.8988752-2140.8987955 0.000000e+00 NaN NaN 1
## 2140.8988752-2140.8987955 0.000000e+00 NaN NaN 1
## 2219.8988752-2140.8987955 0.000000e+00 NaN NaN 1
## 437.8988899-2140.8987955 0.000000e+00 NaN NaN 1
## 605.8988899-2140.8987955 3.469447e-18 NaN NaN NaN
## 1087.8988899-2140.8987955 3.469447e-18 NaN NaN NaN
## 1606.8988899-2140.8987955 3.469447e-18 NaN NaN NaN
## 1992.8988899-2140.8987955 -3.469447e-18 NaN NaN NaN
## 2140.8988899-2140.8987955 3.469447e-18 NaN NaN NaN
## 2219.8988899-2140.8987955 6.938894e-18 NaN NaN NaN
## 437.9340742-2140.8987955 6.938894e-18 NaN NaN NaN
## 605.9340742-2140.8987955 6.938894e-18 NaN NaN NaN
## 1087.9340742-2140.8987955 -1.734723e-17 NaN NaN NaN
## 1606.9340742-2140.8987955 6.938894e-18 NaN NaN NaN
## 1992.9340742-2140.8987955 6.938894e-18 NaN NaN NaN
## 2140.9340742-2140.8987955 6.938894e-18 NaN NaN NaN
## 2219.9340742-2140.8987955 6.938894e-18 NaN NaN NaN
## 437.8988752-2219.8987955 0.000000e+00 NaN NaN 1
## 605.8988752-2219.8987955 0.000000e+00 NaN NaN 1
## 1087.8988752-2219.8987955 0.000000e+00 NaN NaN 1
## 1606.8988752-2219.8987955 0.000000e+00 NaN NaN 1
## 1992.8988752-2219.8987955 0.000000e+00 NaN NaN 1
## 2140.8988752-2219.8987955 0.000000e+00 NaN NaN 1
## 2219.8988752-2219.8987955 0.000000e+00 NaN NaN 1
## 437.8988899-2219.8987955 0.000000e+00 NaN NaN 1
## 605.8988899-2219.8987955 3.469447e-18 NaN NaN NaN
## 1087.8988899-2219.8987955 3.469447e-18 NaN NaN NaN
## 1606.8988899-2219.8987955 3.469447e-18 NaN NaN NaN
## 1992.8988899-2219.8987955 -3.469447e-18 NaN NaN NaN
## 2140.8988899-2219.8987955 3.469447e-18 NaN NaN NaN
## 2219.8988899-2219.8987955 6.938894e-18 NaN NaN NaN
## 437.9340742-2219.8987955 6.938894e-18 NaN NaN NaN
## 605.9340742-2219.8987955 6.938894e-18 NaN NaN NaN
## 1087.9340742-2219.8987955 -1.734723e-17 NaN NaN NaN
## 1606.9340742-2219.8987955 6.938894e-18 NaN NaN NaN
## 1992.9340742-2219.8987955 6.938894e-18 NaN NaN NaN
## 2140.9340742-2219.8987955 6.938894e-18 NaN NaN NaN
## 2219.9340742-2219.8987955 6.938894e-18 NaN NaN NaN
## 605.8988752-437.8988752 0.000000e+00 NaN NaN 1
## 1087.8988752-437.8988752 0.000000e+00 NaN NaN 1
## 1606.8988752-437.8988752 0.000000e+00 NaN NaN 1
## 1992.8988752-437.8988752 0.000000e+00 NaN NaN 1
## 2140.8988752-437.8988752 0.000000e+00 NaN NaN 1
## 2219.8988752-437.8988752 0.000000e+00 NaN NaN 1
## 437.8988899-437.8988752 0.000000e+00 NaN NaN 1
## 605.8988899-437.8988752 3.469447e-18 NaN NaN NaN
## 1087.8988899-437.8988752 3.469447e-18 NaN NaN NaN
## 1606.8988899-437.8988752 3.469447e-18 NaN NaN NaN
## 1992.8988899-437.8988752 -3.469447e-18 NaN NaN NaN
## 2140.8988899-437.8988752 3.469447e-18 NaN NaN NaN
## 2219.8988899-437.8988752 6.938894e-18 NaN NaN NaN
## 437.9340742-437.8988752 6.938894e-18 NaN NaN NaN
## 605.9340742-437.8988752 6.938894e-18 NaN NaN NaN
## 1087.9340742-437.8988752 -1.734723e-17 NaN NaN NaN
## 1606.9340742-437.8988752 6.938894e-18 NaN NaN NaN
## 1992.9340742-437.8988752 6.938894e-18 NaN NaN NaN
## 2140.9340742-437.8988752 6.938894e-18 NaN NaN NaN
## 2219.9340742-437.8988752 6.938894e-18 NaN NaN NaN
## 1087.8988752-605.8988752 0.000000e+00 NaN NaN 1
## 1606.8988752-605.8988752 0.000000e+00 NaN NaN 1
## 1992.8988752-605.8988752 0.000000e+00 NaN NaN 1
## 2140.8988752-605.8988752 0.000000e+00 NaN NaN 1
## 2219.8988752-605.8988752 0.000000e+00 NaN NaN 1
## 437.8988899-605.8988752 0.000000e+00 NaN NaN 1
## 605.8988899-605.8988752 3.469447e-18 NaN NaN NaN
## 1087.8988899-605.8988752 3.469447e-18 NaN NaN NaN
## 1606.8988899-605.8988752 3.469447e-18 NaN NaN NaN
## 1992.8988899-605.8988752 -3.469447e-18 NaN NaN NaN
## 2140.8988899-605.8988752 3.469447e-18 NaN NaN NaN
## 2219.8988899-605.8988752 6.938894e-18 NaN NaN NaN
## 437.9340742-605.8988752 6.938894e-18 NaN NaN NaN
## 605.9340742-605.8988752 6.938894e-18 NaN NaN NaN
## 1087.9340742-605.8988752 -1.734723e-17 NaN NaN NaN
## 1606.9340742-605.8988752 6.938894e-18 NaN NaN NaN
## 1992.9340742-605.8988752 6.938894e-18 NaN NaN NaN
## 2140.9340742-605.8988752 6.938894e-18 NaN NaN NaN
## 2219.9340742-605.8988752 6.938894e-18 NaN NaN NaN
## 1606.8988752-1087.8988752 0.000000e+00 NaN NaN 1
## 1992.8988752-1087.8988752 0.000000e+00 NaN NaN 1
## 2140.8988752-1087.8988752 0.000000e+00 NaN NaN 1
## 2219.8988752-1087.8988752 0.000000e+00 NaN NaN 1
## 437.8988899-1087.8988752 0.000000e+00 NaN NaN 1
## 605.8988899-1087.8988752 3.469447e-18 NaN NaN NaN
## 1087.8988899-1087.8988752 3.469447e-18 NaN NaN NaN
## 1606.8988899-1087.8988752 3.469447e-18 NaN NaN NaN
## 1992.8988899-1087.8988752 -3.469447e-18 NaN NaN NaN
## 2140.8988899-1087.8988752 3.469447e-18 NaN NaN NaN
## 2219.8988899-1087.8988752 6.938894e-18 NaN NaN NaN
## 437.9340742-1087.8988752 6.938894e-18 NaN NaN NaN
## 605.9340742-1087.8988752 6.938894e-18 NaN NaN NaN
## 1087.9340742-1087.8988752 -1.734723e-17 NaN NaN NaN
## 1606.9340742-1087.8988752 6.938894e-18 NaN NaN NaN
## 1992.9340742-1087.8988752 6.938894e-18 NaN NaN NaN
## 2140.9340742-1087.8988752 6.938894e-18 NaN NaN NaN
## 2219.9340742-1087.8988752 6.938894e-18 NaN NaN NaN
## 1992.8988752-1606.8988752 0.000000e+00 NaN NaN 1
## 2140.8988752-1606.8988752 0.000000e+00 NaN NaN 1
## 2219.8988752-1606.8988752 0.000000e+00 NaN NaN 1
## 437.8988899-1606.8988752 0.000000e+00 NaN NaN 1
## 605.8988899-1606.8988752 3.469447e-18 NaN NaN NaN
## 1087.8988899-1606.8988752 3.469447e-18 NaN NaN NaN
## 1606.8988899-1606.8988752 3.469447e-18 NaN NaN NaN
## 1992.8988899-1606.8988752 -3.469447e-18 NaN NaN NaN
## 2140.8988899-1606.8988752 3.469447e-18 NaN NaN NaN
## 2219.8988899-1606.8988752 6.938894e-18 NaN NaN NaN
## 437.9340742-1606.8988752 6.938894e-18 NaN NaN NaN
## 605.9340742-1606.8988752 6.938894e-18 NaN NaN NaN
## 1087.9340742-1606.8988752 -1.734723e-17 NaN NaN NaN
## 1606.9340742-1606.8988752 6.938894e-18 NaN NaN NaN
## 1992.9340742-1606.8988752 6.938894e-18 NaN NaN NaN
## 2140.9340742-1606.8988752 6.938894e-18 NaN NaN NaN
## 2219.9340742-1606.8988752 6.938894e-18 NaN NaN NaN
## 2140.8988752-1992.8988752 0.000000e+00 NaN NaN 1
## 2219.8988752-1992.8988752 0.000000e+00 NaN NaN 1
## 437.8988899-1992.8988752 0.000000e+00 NaN NaN 1
## 605.8988899-1992.8988752 3.469447e-18 NaN NaN NaN
## 1087.8988899-1992.8988752 3.469447e-18 NaN NaN NaN
## 1606.8988899-1992.8988752 3.469447e-18 NaN NaN NaN
## 1992.8988899-1992.8988752 -3.469447e-18 NaN NaN NaN
## 2140.8988899-1992.8988752 3.469447e-18 NaN NaN NaN
## 2219.8988899-1992.8988752 6.938894e-18 NaN NaN NaN
## 437.9340742-1992.8988752 6.938894e-18 NaN NaN NaN
## 605.9340742-1992.8988752 6.938894e-18 NaN NaN NaN
## 1087.9340742-1992.8988752 -1.734723e-17 NaN NaN NaN
## 1606.9340742-1992.8988752 6.938894e-18 NaN NaN NaN
## 1992.9340742-1992.8988752 6.938894e-18 NaN NaN NaN
## 2140.9340742-1992.8988752 6.938894e-18 NaN NaN NaN
## 2219.9340742-1992.8988752 6.938894e-18 NaN NaN NaN
## 2219.8988752-2140.8988752 0.000000e+00 NaN NaN 1
## 437.8988899-2140.8988752 0.000000e+00 NaN NaN 1
## 605.8988899-2140.8988752 3.469447e-18 NaN NaN NaN
## 1087.8988899-2140.8988752 3.469447e-18 NaN NaN NaN
## 1606.8988899-2140.8988752 3.469447e-18 NaN NaN NaN
## 1992.8988899-2140.8988752 -3.469447e-18 NaN NaN NaN
## 2140.8988899-2140.8988752 3.469447e-18 NaN NaN NaN
## 2219.8988899-2140.8988752 6.938894e-18 NaN NaN NaN
## 437.9340742-2140.8988752 6.938894e-18 NaN NaN NaN
## 605.9340742-2140.8988752 6.938894e-18 NaN NaN NaN
## 1087.9340742-2140.8988752 -1.734723e-17 NaN NaN NaN
## 1606.9340742-2140.8988752 6.938894e-18 NaN NaN NaN
## 1992.9340742-2140.8988752 6.938894e-18 NaN NaN NaN
## 2140.9340742-2140.8988752 6.938894e-18 NaN NaN NaN
## 2219.9340742-2140.8988752 6.938894e-18 NaN NaN NaN
## 437.8988899-2219.8988752 0.000000e+00 NaN NaN 1
## 605.8988899-2219.8988752 3.469447e-18 NaN NaN NaN
## 1087.8988899-2219.8988752 3.469447e-18 NaN NaN NaN
## 1606.8988899-2219.8988752 3.469447e-18 NaN NaN NaN
## 1992.8988899-2219.8988752 -3.469447e-18 NaN NaN NaN
## 2140.8988899-2219.8988752 3.469447e-18 NaN NaN NaN
## 2219.8988899-2219.8988752 6.938894e-18 NaN NaN NaN
## 437.9340742-2219.8988752 6.938894e-18 NaN NaN NaN
## 605.9340742-2219.8988752 6.938894e-18 NaN NaN NaN
## 1087.9340742-2219.8988752 -1.734723e-17 NaN NaN NaN
## 1606.9340742-2219.8988752 6.938894e-18 NaN NaN NaN
## 1992.9340742-2219.8988752 6.938894e-18 NaN NaN NaN
## 2140.9340742-2219.8988752 6.938894e-18 NaN NaN NaN
## 2219.9340742-2219.8988752 6.938894e-18 NaN NaN NaN
## 605.8988899-437.8988899 3.469447e-18 NaN NaN NaN
## 1087.8988899-437.8988899 3.469447e-18 NaN NaN NaN
## 1606.8988899-437.8988899 3.469447e-18 NaN NaN NaN
## 1992.8988899-437.8988899 -3.469447e-18 NaN NaN NaN
## 2140.8988899-437.8988899 3.469447e-18 NaN NaN NaN
## 2219.8988899-437.8988899 6.938894e-18 NaN NaN NaN
## 437.9340742-437.8988899 6.938894e-18 NaN NaN NaN
## 605.9340742-437.8988899 6.938894e-18 NaN NaN NaN
## 1087.9340742-437.8988899 -1.734723e-17 NaN NaN NaN
## 1606.9340742-437.8988899 6.938894e-18 NaN NaN NaN
## 1992.9340742-437.8988899 6.938894e-18 NaN NaN NaN
## 2140.9340742-437.8988899 6.938894e-18 NaN NaN NaN
## 2219.9340742-437.8988899 6.938894e-18 NaN NaN NaN
## 1087.8988899-605.8988899 0.000000e+00 NaN NaN 1
## 1606.8988899-605.8988899 0.000000e+00 NaN NaN 1
## 1992.8988899-605.8988899 -6.938894e-18 NaN NaN NaN
## 2140.8988899-605.8988899 0.000000e+00 NaN NaN 1
## 2219.8988899-605.8988899 3.469447e-18 NaN NaN NaN
## 437.9340742-605.8988899 3.469447e-18 NaN NaN NaN
## 605.9340742-605.8988899 3.469447e-18 NaN NaN NaN
## 1087.9340742-605.8988899 -2.081668e-17 NaN NaN NaN
## 1606.9340742-605.8988899 3.469447e-18 NaN NaN NaN
## 1992.9340742-605.8988899 3.469447e-18 NaN NaN NaN
## 2140.9340742-605.8988899 3.469447e-18 NaN NaN NaN
## 2219.9340742-605.8988899 3.469447e-18 NaN NaN NaN
## 1606.8988899-1087.8988899 0.000000e+00 NaN NaN 1
## 1992.8988899-1087.8988899 -6.938894e-18 NaN NaN NaN
## 2140.8988899-1087.8988899 0.000000e+00 NaN NaN 1
## 2219.8988899-1087.8988899 3.469447e-18 NaN NaN NaN
## 437.9340742-1087.8988899 3.469447e-18 NaN NaN NaN
## 605.9340742-1087.8988899 3.469447e-18 NaN NaN NaN
## 1087.9340742-1087.8988899 -2.081668e-17 NaN NaN NaN
## 1606.9340742-1087.8988899 3.469447e-18 NaN NaN NaN
## 1992.9340742-1087.8988899 3.469447e-18 NaN NaN NaN
## 2140.9340742-1087.8988899 3.469447e-18 NaN NaN NaN
## 2219.9340742-1087.8988899 3.469447e-18 NaN NaN NaN
## 1992.8988899-1606.8988899 -6.938894e-18 NaN NaN NaN
## 2140.8988899-1606.8988899 0.000000e+00 NaN NaN 1
## 2219.8988899-1606.8988899 3.469447e-18 NaN NaN NaN
## 437.9340742-1606.8988899 3.469447e-18 NaN NaN NaN
## 605.9340742-1606.8988899 3.469447e-18 NaN NaN NaN
## 1087.9340742-1606.8988899 -2.081668e-17 NaN NaN NaN
## 1606.9340742-1606.8988899 3.469447e-18 NaN NaN NaN
## 1992.9340742-1606.8988899 3.469447e-18 NaN NaN NaN
## 2140.9340742-1606.8988899 3.469447e-18 NaN NaN NaN
## 2219.9340742-1606.8988899 3.469447e-18 NaN NaN NaN
## 2140.8988899-1992.8988899 6.938894e-18 NaN NaN NaN
## 2219.8988899-1992.8988899 1.040834e-17 NaN NaN NaN
## 437.9340742-1992.8988899 1.040834e-17 NaN NaN NaN
## 605.9340742-1992.8988899 1.040834e-17 NaN NaN NaN
## 1087.9340742-1992.8988899 -1.387779e-17 NaN NaN NaN
## 1606.9340742-1992.8988899 1.040834e-17 NaN NaN NaN
## 1992.9340742-1992.8988899 1.040834e-17 NaN NaN NaN
## 2140.9340742-1992.8988899 1.040834e-17 NaN NaN NaN
## 2219.9340742-1992.8988899 1.040834e-17 NaN NaN NaN
## 2219.8988899-2140.8988899 3.469447e-18 NaN NaN NaN
## 437.9340742-2140.8988899 3.469447e-18 NaN NaN NaN
## 605.9340742-2140.8988899 3.469447e-18 NaN NaN NaN
## 1087.9340742-2140.8988899 -2.081668e-17 NaN NaN NaN
## 1606.9340742-2140.8988899 3.469447e-18 NaN NaN NaN
## 1992.9340742-2140.8988899 3.469447e-18 NaN NaN NaN
## 2140.9340742-2140.8988899 3.469447e-18 NaN NaN NaN
## 2219.9340742-2140.8988899 3.469447e-18 NaN NaN NaN
## 437.9340742-2219.8988899 0.000000e+00 NaN NaN 1
## 605.9340742-2219.8988899 0.000000e+00 NaN NaN 1
## 1087.9340742-2219.8988899 -2.428613e-17 NaN NaN NaN
## 1606.9340742-2219.8988899 0.000000e+00 NaN NaN 1
## 1992.9340742-2219.8988899 0.000000e+00 NaN NaN 1
## 2140.9340742-2219.8988899 0.000000e+00 NaN NaN 1
## 2219.9340742-2219.8988899 0.000000e+00 NaN NaN 1
## 605.9340742-437.9340742 0.000000e+00 NaN NaN 1
## 1087.9340742-437.9340742 -2.428613e-17 NaN NaN NaN
## 1606.9340742-437.9340742 0.000000e+00 NaN NaN 1
## 1992.9340742-437.9340742 0.000000e+00 NaN NaN 1
## 2140.9340742-437.9340742 0.000000e+00 NaN NaN 1
## 2219.9340742-437.9340742 0.000000e+00 NaN NaN 1
## 1087.9340742-605.9340742 -2.428613e-17 NaN NaN NaN
## 1606.9340742-605.9340742 0.000000e+00 NaN NaN 1
## 1992.9340742-605.9340742 0.000000e+00 NaN NaN 1
## 2140.9340742-605.9340742 0.000000e+00 NaN NaN 1
## 2219.9340742-605.9340742 0.000000e+00 NaN NaN 1
## 1606.9340742-1087.9340742 2.428613e-17 NaN NaN NaN
## 1992.9340742-1087.9340742 2.428613e-17 NaN NaN NaN
## 2140.9340742-1087.9340742 2.428613e-17 NaN NaN NaN
## 2219.9340742-1087.9340742 2.428613e-17 NaN NaN NaN
## 1992.9340742-1606.9340742 0.000000e+00 NaN NaN 1
## 2140.9340742-1606.9340742 0.000000e+00 NaN NaN 1
## 2219.9340742-1606.9340742 0.000000e+00 NaN NaN 1
## 2140.9340742-1992.9340742 0.000000e+00 NaN NaN 1
## 2219.9340742-1992.9340742 0.000000e+00 NaN NaN 1
## 2219.9340742-2140.9340742 0.000000e+00 NaN NaN 1
Question: Do growing degree days significantly influence the community composition (beta diversity) within Populus?
# Filter data for Populus_tremuloides
populus_data <- asv_scaled_noPlants_Phen_filt_LMM[asv_scaled_noPlants_Phen_filt_LMM$Species ==
"Populus_tremuloides", ]
# Perform PERMANOVA for Populus_tremuloides
permanova_populus_beta <- adonis2(dist.mat_populus ~ GDD_5C * Plant_ID, data = populus_data,
permutations = 10000)
# Print PERMANOVA results for Populus_tremuloides
print(permanova_populus_beta)
## Permutation test for adonis under reduced model
## Permutation: free
## Number of permutations: 10000
##
## adonis2(formula = dist.mat_populus ~ GDD_5C * Plant_ID, data = populus_data, permutations = 10000)
## Df SumOfSqs R2 F Pr(>F)
## Model 9 3.7913 0.25246 0.9756 0.7003
## Residual 26 11.2264 0.74754
## Total 35 15.0177 1.00000
# Spearman correlation between Axis 1 and GDD_5C
cor_axis1_gdd_spearman_pop <- cor(pcoa.table_populus$Axis.1, populus_data$GDD_5C,
method = "spearman")
# Spearman correlation between Axis 2 and GDD_5C
cor_axis2_gdd_spearman_pop <- cor(pcoa.table_populus$Axis.2, populus_data$GDD_5C,
method = "spearman")
# Spearman correlation between Axis 2 and GDD_5C
cor_axis3_gdd_spearman_pop <- cor(pcoa.table_populus$Axis.3, populus_data$GDD_5C,
method = "spearman")
# Print results
cat("Spearman correlation between Axis 1 and GDD_5C:", cor_axis1_gdd_spearman_pop,
"\n")
## Spearman correlation between Axis 1 and GDD_5C: -0.3373587
cat("Spearman correlation between Axis 2 and GDD_5C:", cor_axis2_gdd_spearman_pop,
"\n")
## Spearman correlation between Axis 2 and GDD_5C: -0.1704344
cat("Spearman correlation between Axis 3 and GDD_5C:", cor_axis2_gdd_spearman_pop,
"\n")
## Spearman correlation between Axis 3 and GDD_5C: -0.1704344
# Spearman correlation test for Axis 1
cor_test_axis1_spearman_pop <- cor.test(pcoa.table_populus$Axis.1, populus_data$GDD_5C,
method = "spearman")
## Warning in cor.test.default(pcoa.table_populus$Axis.1, populus_data$GDD_5C, :
## Cannot compute exact p-value with ties
# Spearman correlation test for Axis 2
cor_test_axis2_spearman_pop <- cor.test(pcoa.table_populus$Axis.2, populus_data$GDD_5C,
method = "spearman")
## Warning in cor.test.default(pcoa.table_populus$Axis.2, populus_data$GDD_5C, :
## Cannot compute exact p-value with ties
# Spearman correlation test for Axis 3
cor_test_axis3_spearman_pop <- cor.test(pcoa.table_populus$Axis.3, populus_data$GDD_5C,
method = "spearman")
## Warning in cor.test.default(pcoa.table_populus$Axis.3, populus_data$GDD_5C, :
## Cannot compute exact p-value with ties
# Print test results
print(cor_test_axis1_spearman_pop)
##
## Spearman's rank correlation rho
##
## data: pcoa.table_populus$Axis.1 and populus_data$GDD_5C
## S = 10391, p-value = 0.04421
## alternative hypothesis: true rho is not equal to 0
## sample estimates:
## rho
## -0.3373587
print(cor_test_axis2_spearman_pop)
##
## Spearman's rank correlation rho
##
## data: pcoa.table_populus$Axis.2 and populus_data$GDD_5C
## S = 9094.3, p-value = 0.3203
## alternative hypothesis: true rho is not equal to 0
## sample estimates:
## rho
## -0.1704344
print(cor_test_axis3_spearman_pop)
##
## Spearman's rank correlation rho
##
## data: pcoa.table_populus$Axis.3 and populus_data$GDD_5C
## S = 5714.4, p-value = 0.1189
## alternative hypothesis: true rho is not equal to 0
## sample estimates:
## rho
## 0.2645568
# Perform PERMANOVA
library(vegan)
# Now, perform the PERMANOVA analysis with the updated formula
permanova_traits_beta_area <- with(asv_scaled_noPlants_Phen_filt_LMM, adonis2(dist.mat ~
Species + GDD_5C + LMA + LDMC + EWT + Carea + Narea + solubles_area + hemicellulose_area +
cellulose_area + lignin_area + chlA_area + chlB_area + car_area + Cu_area +
Fe_area + K_area + Mg_area + Mn_area + Na_area + P_area + Zn_area, na.action = na.exclude,
permutations = 10000, by = "term"))
# Summarize the PERMANOVA results
summary(permanova_traits_beta_area)
## Df SumOfSqs R2 F
## Min. : 1.000 Min. : 0.2944 Min. :0.009653 Min. :0.8036
## 1st Qu.: 1.000 1st Qu.: 0.3910 1st Qu.:0.012819 1st Qu.:1.0549
## Median : 1.000 Median : 0.4265 Median :0.013982 Median :1.1248
## Mean : 5.833 Mean : 2.5419 Mean :0.083333 Mean :1.6023
## 3rd Qu.: 1.000 3rd Qu.: 0.5058 3rd Qu.:0.016582 3rd Qu.:1.2837
## Max. :70.000 Max. :30.5028 Max. :1.000000 Max. :9.1445
## NA's :2
## Pr(>F)
## Min. :0.0001
## 1st Qu.:0.1053
## Median :0.2398
## Mean :0.2834
## 3rd Qu.:0.3178
## Max. :0.8252
## NA's :2
permanova_traits_beta_area
## Permutation test for adonis under reduced model
## Terms added sequentially (first to last)
## Permutation: free
## Number of permutations: 10000
##
## adonis2(formula = dist.mat ~ Species + GDD_5C + LMA + LDMC + EWT + Carea + Narea + solubles_area + hemicellulose_area + cellulose_area + lignin_area + chlA_area + chlB_area + car_area + Cu_area + Fe_area + K_area + Mg_area + Mn_area + Na_area + P_area + Zn_area, permutations = 10000, by = "term", na.action = na.exclude)
## Df SumOfSqs R2 F Pr(>F)
## Species 1 3.3505 0.10984 9.1445 9.999e-05 ***
## GDD_5C 1 1.2520 0.04105 3.4171 9.999e-05 ***
## LMA 1 0.5978 0.01960 1.6315 0.02180 *
## LDMC 1 0.4802 0.01574 1.3106 0.09389 .
## EWT 1 0.3300 0.01082 0.9007 0.61924
## Carea 1 0.4042 0.01325 1.1032 0.26227
## Narea 1 0.4478 0.01468 1.2222 0.14619
## solubles_area 1 0.2944 0.00965 0.8036 0.82522
## hemicellulose_area 1 0.3314 0.01086 0.9045 0.61754
## cellulose_area 1 0.3843 0.01260 1.0488 0.32257
## lignin_area 1 0.2962 0.00971 0.8084 0.82422
## chlA_area 1 0.4498 0.01475 1.2277 0.12659
## chlB_area 1 0.4344 0.01424 1.1856 0.17448
## car_area 1 0.3946 0.01294 1.0771 0.30347
## Cu_area 1 0.5825 0.01910 1.5898 0.02490 *
## Fe_area 1 0.4598 0.01507 1.2549 0.12139
## K_area 1 0.3343 0.01096 0.9124 0.59854
## Mg_area 1 0.4186 0.01372 1.1425 0.22038
## Mn_area 1 0.4057 0.01330 1.1071 0.25927
## Na_area 1 0.4003 0.01312 1.0925 0.28157
## P_area 1 0.4739 0.01554 1.2933 0.09999 .
## Zn_area 1 0.3933 0.01289 1.0734 0.29067
## Residual 48 17.5869 0.57657
## Total 70 30.5028 1.00000
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Signif. Traits: LMA, LDMC (p=0.094), lignin_mass (0.098), Mg_mass (p=0.095),
# Zn_mass (p=0.064)
# Join trait data
# asv_scaled_noPlants_Phen_filt_LMM<-plyr::join(asv_scaled_noPlants_Phen_filt_LMM,
# refl_trait_data, by='sample_id', type='left')
# Impute NAs with median for numeric columns
asv_scaled_noPlants_Phen_filt_LMM[, sapply(asv_scaled_noPlants_Phen_filt_LMM, is.numeric)] <- lapply(asv_scaled_noPlants_Phen_filt_LMM[,
sapply(asv_scaled_noPlants_Phen_filt_LMM, is.numeric)], function(x) ifelse(is.na(x),
median(x, na.rm = TRUE), x))
library(dplyr)
library(corrplot)
## corrplot 0.95 loaded
# 1) Pick continuous traits you plan to test (include numeric GDD if you'll
# model it as numeric)
traits_raw <- asv_scaled_noPlants_Phen_filt_LMM %>%
dplyr::select(GDD_5C, LMA, LDMC, EWT, Narea, Carea, solubles_area, hemicellulose_area,
cellulose_area, lignin_area, chlA_area, chlB_area, car_area, Al_area, Ca_area,
Cu_area, Fe_area, K_area, Mg_area, Mn_area, Na_area, P_area, Zn_area) # add/remove as needed
# 2) Ensure numeric only + scale (center/scale helps downstream)
traits_num <- traits_raw %>%
dplyr::select(where(is.numeric)) %>%
dplyr::mutate(across(everything(), as.numeric))
traits_scaled <- scale(traits_num)
# 3) Correlation matrix (Pearson; switch to method='spearman' if distributions
# are gnarly)
cor_mat <- cor(traits_scaled, use = "pairwise.complete.obs", method = "pearson")
round(cor_mat, 2)
## GDD_5C LMA LDMC EWT Narea Carea solubles_area
## GDD_5C 1.00 0.06 0.41 -0.26 -0.27 0.10 0.05
## LMA 0.06 1.00 0.78 0.80 0.84 1.00 0.99
## LDMC 0.41 0.78 1.00 0.33 0.55 0.80 0.79
## EWT -0.26 0.80 0.33 1.00 0.73 0.77 0.80
## Narea -0.27 0.84 0.55 0.73 1.00 0.84 0.81
## Carea 0.10 1.00 0.80 0.77 0.84 1.00 0.98
## solubles_area 0.05 0.99 0.79 0.80 0.81 0.98 1.00
## hemicellulose_area 0.18 0.22 0.19 0.00 0.31 0.24 0.09
## cellulose_area -0.05 0.90 0.58 0.86 0.70 0.88 0.89
## lignin_area 0.09 0.46 0.32 0.31 0.55 0.49 0.35
## chlA_area -0.28 0.64 0.38 0.64 0.75 0.64 0.62
## chlB_area -0.15 0.67 0.47 0.63 0.73 0.68 0.65
## car_area -0.26 0.67 0.36 0.73 0.72 0.66 0.66
## Al_area 0.59 0.52 0.63 0.29 0.19 0.52 0.54
## Ca_area 0.65 0.61 0.65 0.40 0.26 0.61 0.61
## Cu_area -0.21 0.76 0.46 0.75 0.76 0.74 0.76
## Fe_area 0.32 0.64 0.61 0.49 0.46 0.65 0.64
## K_area -0.08 0.74 0.43 0.76 0.61 0.72 0.73
## Mg_area 0.07 0.07 0.21 -0.12 0.24 0.09 0.06
## Mn_area 0.18 -0.40 -0.23 -0.47 -0.28 -0.37 -0.42
## Na_area -0.10 0.51 0.31 0.52 0.40 0.49 0.51
## P_area -0.26 0.36 0.11 0.42 0.50 0.36 0.34
## Zn_area 0.02 -0.22 -0.02 -0.32 -0.06 -0.22 -0.20
## hemicellulose_area cellulose_area lignin_area chlA_area
## GDD_5C 0.18 -0.05 0.09 -0.28
## LMA 0.22 0.90 0.46 0.64
## LDMC 0.19 0.58 0.32 0.38
## EWT 0.00 0.86 0.31 0.64
## Narea 0.31 0.70 0.55 0.75
## Carea 0.24 0.88 0.49 0.64
## solubles_area 0.09 0.89 0.35 0.62
## hemicellulose_area 1.00 0.00 0.61 0.13
## cellulose_area 0.00 1.00 0.29 0.59
## lignin_area 0.61 0.29 1.00 0.41
## chlA_area 0.13 0.59 0.41 1.00
## chlB_area 0.12 0.64 0.42 0.98
## car_area 0.07 0.65 0.37 0.96
## Al_area 0.01 0.49 0.01 0.09
## Ca_area 0.06 0.57 0.24 0.19
## Cu_area -0.01 0.83 0.25 0.58
## Fe_area 0.08 0.58 0.23 0.48
## K_area 0.00 0.81 0.30 0.51
## Mg_area 0.40 -0.24 0.18 0.05
## Mn_area 0.46 -0.63 0.02 -0.38
## Na_area -0.01 0.60 -0.01 0.25
## P_area 0.24 0.25 0.32 0.36
## Zn_area -0.01 -0.30 -0.13 -0.15
## chlB_area car_area Al_area Ca_area Cu_area Fe_area K_area
## GDD_5C -0.15 -0.26 0.59 0.65 -0.21 0.32 -0.08
## LMA 0.67 0.67 0.52 0.61 0.76 0.64 0.74
## LDMC 0.47 0.36 0.63 0.65 0.46 0.61 0.43
## EWT 0.63 0.73 0.29 0.40 0.75 0.49 0.76
## Narea 0.73 0.72 0.19 0.26 0.76 0.46 0.61
## Carea 0.68 0.66 0.52 0.61 0.74 0.65 0.72
## solubles_area 0.65 0.66 0.54 0.61 0.76 0.64 0.73
## hemicellulose_area 0.12 0.07 0.01 0.06 -0.01 0.08 0.00
## cellulose_area 0.64 0.65 0.49 0.57 0.83 0.58 0.81
## lignin_area 0.42 0.37 0.01 0.24 0.25 0.23 0.30
## chlA_area 0.98 0.96 0.09 0.19 0.58 0.48 0.51
## chlB_area 1.00 0.92 0.21 0.31 0.59 0.57 0.54
## car_area 0.92 1.00 0.10 0.25 0.60 0.48 0.58
## Al_area 0.21 0.10 1.00 0.76 0.46 0.77 0.39
## Ca_area 0.31 0.25 0.76 1.00 0.40 0.66 0.47
## Cu_area 0.59 0.60 0.46 0.40 1.00 0.61 0.74
## Fe_area 0.57 0.48 0.77 0.66 0.61 1.00 0.43
## K_area 0.54 0.58 0.39 0.47 0.74 0.43 1.00
## Mg_area 0.00 0.01 -0.01 0.01 -0.04 -0.06 -0.02
## Mn_area -0.45 -0.41 -0.24 -0.31 -0.57 -0.40 -0.41
## Na_area 0.26 0.28 0.46 0.24 0.56 0.23 0.44
## P_area 0.27 0.40 0.00 -0.03 0.44 0.09 0.49
## Zn_area -0.16 -0.18 -0.13 0.01 -0.10 -0.24 -0.20
## Mg_area Mn_area Na_area P_area Zn_area
## GDD_5C 0.07 0.18 -0.10 -0.26 0.02
## LMA 0.07 -0.40 0.51 0.36 -0.22
## LDMC 0.21 -0.23 0.31 0.11 -0.02
## EWT -0.12 -0.47 0.52 0.42 -0.32
## Narea 0.24 -0.28 0.40 0.50 -0.06
## Carea 0.09 -0.37 0.49 0.36 -0.22
## solubles_area 0.06 -0.42 0.51 0.34 -0.20
## hemicellulose_area 0.40 0.46 -0.01 0.24 -0.01
## cellulose_area -0.24 -0.63 0.60 0.25 -0.30
## lignin_area 0.18 0.02 -0.01 0.32 -0.13
## chlA_area 0.05 -0.38 0.25 0.36 -0.15
## chlB_area 0.00 -0.45 0.26 0.27 -0.16
## car_area 0.01 -0.41 0.28 0.40 -0.18
## Al_area -0.01 -0.24 0.46 0.00 -0.13
## Ca_area 0.01 -0.31 0.24 -0.03 0.01
## Cu_area -0.04 -0.57 0.56 0.44 -0.10
## Fe_area -0.06 -0.40 0.23 0.09 -0.24
## K_area -0.02 -0.41 0.44 0.49 -0.20
## Mg_area 1.00 0.57 -0.01 0.51 0.48
## Mn_area 0.57 1.00 -0.27 0.20 0.11
## Na_area -0.01 -0.27 1.00 0.31 -0.12
## P_area 0.51 0.20 0.31 1.00 0.03
## Zn_area 0.48 0.11 -0.12 0.03 1.00
corrplot(cor_mat, method = "color", type = "upper", tl.col = "black")
# Subset the numeric columns only from your data
numeric_vars_all_traits <- asv_scaled_noPlants_Phen_filt_LMM[, c("LMA", "LDMC", "EWT",
"Narea", "Carea", "solubles_area", "hemicellulose_area", "cellulose_area", "lignin_area",
"chlA_area", "chlB_area", "car_area", "Al_area", "Ca_area", "Cu_area", "Fe_area",
"K_area", "Mg_area", "Mn_area", "Na_area", "P_area", "Zn_area")]
# Compute the correlation matrix
cor_matrix_all_traits <- cor(numeric_vars_all_traits, use = "complete.obs")
# View the correlation matrix
print(cor_matrix_all_traits)
## LMA LDMC EWT Narea Carea
## LMA 1.00000000 0.77784878 0.803933967 0.83719869 0.99664001
## LDMC 0.77784878 1.00000000 0.334398251 0.55471422 0.80461932
## EWT 0.80393397 0.33439825 1.000000000 0.72738538 0.77496970
## Narea 0.83719869 0.55471422 0.727385378 1.00000000 0.83961199
## Carea 0.99664001 0.80461932 0.774969699 0.83961199 1.00000000
## solubles_area 0.98789759 0.78846464 0.798417932 0.80768924 0.98207692
## hemicellulose_area 0.21823056 0.18757969 -0.001015366 0.30626818 0.24114733
## cellulose_area 0.90005374 0.58392878 0.855001814 0.70379580 0.87955238
## lignin_area 0.46146476 0.31949222 0.313274657 0.55127504 0.48547832
## chlA_area 0.63584388 0.37829422 0.639996655 0.75189174 0.63529146
## chlB_area 0.67332719 0.46527304 0.631677737 0.72813298 0.67587276
## car_area 0.67216870 0.36148031 0.728624789 0.72375226 0.66381195
## Al_area 0.51922468 0.63066229 0.288200547 0.19144482 0.52310446
## Ca_area 0.61463798 0.65329073 0.395811666 0.26245898 0.60868141
## Cu_area 0.76072334 0.45941363 0.746371123 0.75717844 0.74211483
## Fe_area 0.64154681 0.60847154 0.492015510 0.46426869 0.64831087
## K_area 0.74400000 0.42865663 0.760696319 0.60879627 0.72067478
## Mg_area 0.06601953 0.20771390 -0.121509977 0.23591477 0.08802583
## Mn_area -0.39644276 -0.23166321 -0.474232364 -0.27598075 -0.37400527
## Na_area 0.50595715 0.31438229 0.523831612 0.40008488 0.48926984
## P_area 0.35921185 0.10845442 0.416440056 0.50248582 0.36315179
## Zn_area -0.21990872 -0.01727471 -0.315778398 -0.05786244 -0.21806011
## solubles_area hemicellulose_area cellulose_area lignin_area
## LMA 0.98789759 0.218230557 0.900053740 0.461464763
## LDMC 0.78846464 0.187579690 0.583928782 0.319492219
## EWT 0.79841793 -0.001015366 0.855001814 0.313274657
## Narea 0.80768924 0.306268177 0.703795802 0.551275044
## Carea 0.98207692 0.241147333 0.879552375 0.485478324
## solubles_area 1.00000000 0.094964495 0.890352694 0.348989072
## hemicellulose_area 0.09496449 1.000000000 -0.001010929 0.606753051
## cellulose_area 0.89035269 -0.001010929 1.000000000 0.285443773
## lignin_area 0.34898907 0.606753051 0.285443773 1.000000000
## chlA_area 0.61717072 0.132370481 0.586649665 0.406344680
## chlB_area 0.65312317 0.121223078 0.635694939 0.416246953
## car_area 0.65967229 0.070262719 0.654022783 0.368619870
## Al_area 0.53988217 0.007608684 0.486832571 0.008226779
## Ca_area 0.61336682 0.062499237 0.570493210 0.243715255
## Cu_area 0.75601146 -0.009557881 0.830104551 0.246796222
## Fe_area 0.64315153 0.082639051 0.581206258 0.229653708
## K_area 0.73485694 -0.002281387 0.805844733 0.298350266
## Mg_area 0.06347102 0.398043251 -0.237300363 0.175269856
## Mn_area -0.42431712 0.462202632 -0.631429915 0.021097345
## Na_area 0.51442916 -0.010799349 0.595585374 -0.005982410
## P_area 0.33557800 0.238108384 0.250252832 0.316872884
## Zn_area -0.20013256 -0.007065023 -0.302779994 -0.129878348
## chlA_area chlB_area car_area Al_area
## LMA 0.63584388 0.673327190 0.67216870 0.519224683
## LDMC 0.37829422 0.465273036 0.36148031 0.630662287
## EWT 0.63999665 0.631677737 0.72862479 0.288200547
## Narea 0.75189174 0.728132984 0.72375226 0.191444820
## Carea 0.63529146 0.675872756 0.66381195 0.523104455
## solubles_area 0.61717072 0.653123169 0.65967229 0.539882165
## hemicellulose_area 0.13237048 0.121223078 0.07026272 0.007608684
## cellulose_area 0.58664966 0.635694939 0.65402278 0.486832571
## lignin_area 0.40634468 0.416246953 0.36861987 0.008226779
## chlA_area 1.00000000 0.977370706 0.96056101 0.091619035
## chlB_area 0.97737071 1.000000000 0.92394445 0.214944631
## car_area 0.96056101 0.923944454 1.00000000 0.101650875
## Al_area 0.09161904 0.214944631 0.10165088 1.000000000
## Ca_area 0.19183046 0.312918356 0.25007892 0.756329500
## Cu_area 0.57680215 0.589651974 0.60494592 0.459211340
## Fe_area 0.48405139 0.569794883 0.47652721 0.773243065
## K_area 0.50740817 0.536826166 0.57712775 0.387896291
## Mg_area 0.05055115 -0.004691002 0.01166258 -0.008310881
## Mn_area -0.37812652 -0.449637726 -0.40537528 -0.238446268
## Na_area 0.25091026 0.262043218 0.28400359 0.458983769
## P_area 0.36346493 0.270137268 0.39948889 -0.002090528
## Zn_area -0.14813145 -0.159523900 -0.17973815 -0.134787275
## Ca_area Cu_area Fe_area K_area
## LMA 0.614637982 0.760723339 0.64154681 0.744000002
## LDMC 0.653290735 0.459413628 0.60847154 0.428656633
## EWT 0.395811666 0.746371123 0.49201551 0.760696319
## Narea 0.262458982 0.757178436 0.46426869 0.608796268
## Carea 0.608681407 0.742114829 0.64831087 0.720674785
## solubles_area 0.613366821 0.756011463 0.64315153 0.734856943
## hemicellulose_area 0.062499237 -0.009557881 0.08263905 -0.002281387
## cellulose_area 0.570493210 0.830104551 0.58120626 0.805844733
## lignin_area 0.243715255 0.246796222 0.22965371 0.298350266
## chlA_area 0.191830456 0.576802152 0.48405139 0.507408167
## chlB_area 0.312918356 0.589651974 0.56979488 0.536826166
## car_area 0.250078925 0.604945919 0.47652721 0.577127746
## Al_area 0.756329500 0.459211340 0.77324307 0.387896291
## Ca_area 1.000000000 0.395573293 0.65806692 0.470957085
## Cu_area 0.395573293 1.000000000 0.61308369 0.743807228
## Fe_area 0.658066919 0.613083692 1.00000000 0.429648944
## K_area 0.470957085 0.743807228 0.42964894 1.000000000
## Mg_area 0.013259440 -0.037583063 -0.05720742 -0.020824475
## Mn_area -0.314805125 -0.567297399 -0.39964832 -0.412174288
## Na_area 0.241070375 0.563323474 0.22971725 0.441245502
## P_area -0.034732855 0.435267483 0.09289419 0.487937830
## Zn_area 0.006695422 -0.101928421 -0.23998906 -0.197555798
## Mg_area Mn_area Na_area P_area
## LMA 0.066019527 -0.39644276 0.505957151 0.359211847
## LDMC 0.207713902 -0.23166321 0.314382294 0.108454423
## EWT -0.121509977 -0.47423236 0.523831612 0.416440056
## Narea 0.235914770 -0.27598075 0.400084881 0.502485822
## Carea 0.088025825 -0.37400527 0.489269844 0.363151793
## solubles_area 0.063471025 -0.42431712 0.514429156 0.335577999
## hemicellulose_area 0.398043251 0.46220263 -0.010799349 0.238108384
## cellulose_area -0.237300363 -0.63142992 0.595585374 0.250252832
## lignin_area 0.175269856 0.02109735 -0.005982410 0.316872884
## chlA_area 0.050551154 -0.37812652 0.250910258 0.363464930
## chlB_area -0.004691002 -0.44963773 0.262043218 0.270137268
## car_area 0.011662576 -0.40537528 0.284003591 0.399488885
## Al_area -0.008310881 -0.23844627 0.458983769 -0.002090528
## Ca_area 0.013259440 -0.31480513 0.241070375 -0.034732855
## Cu_area -0.037583063 -0.56729740 0.563323474 0.435267483
## Fe_area -0.057207421 -0.39964832 0.229717251 0.092894194
## K_area -0.020824475 -0.41217429 0.441245502 0.487937830
## Mg_area 1.000000000 0.56637830 -0.006255007 0.510945311
## Mn_area 0.566378301 1.00000000 -0.266053971 0.196707659
## Na_area -0.006255007 -0.26605397 1.000000000 0.311416720
## P_area 0.510945311 0.19670766 0.311416720 1.000000000
## Zn_area 0.477617373 0.10548235 -0.116540143 0.028881425
## Zn_area
## LMA -0.219908721
## LDMC -0.017274709
## EWT -0.315778398
## Narea -0.057862440
## Carea -0.218060114
## solubles_area -0.200132564
## hemicellulose_area -0.007065023
## cellulose_area -0.302779994
## lignin_area -0.129878348
## chlA_area -0.148131455
## chlB_area -0.159523900
## car_area -0.179738154
## Al_area -0.134787275
## Ca_area 0.006695422
## Cu_area -0.101928421
## Fe_area -0.239989060
## K_area -0.197555798
## Mg_area 0.477617373
## Mn_area 0.105482349
## Na_area -0.116540143
## P_area 0.028881425
## Zn_area 1.000000000
library(dplyr)
library(vegan)
## ---------- Inputs you already have ---------- traits_scaled: matrix from
## scale(), includes GDD_5C + all continuous traits cor_mat: full Pearson
## correlation matrix you computed dist.mat: your Bray–Curtis distance matrix
## (class 'dist')
# 0) Make data frame versions
traits_df <- as.data.frame(traits_scaled)
stopifnot(inherits(dist.mat, "dist"))
labs <- attr(dist.mat, "Labels")
# Align rows (samples) between traits and distance labels
traits_df <- traits_df[labs, , drop = FALSE]
# 1) Split out GDD and trait names
all_cols <- colnames(traits_df)
stopifnot("GDD_5C" %in% all_cols)
trait_names <- setdiff(all_cols, "GDD_5C")
traits_noGDD <- traits_df[, trait_names, drop = FALSE]
# 2) Cluster traits by correlation to get a cluster ID (|r| >= 0.7 grouped)
cor_noGDD <- cor(traits_noGDD, use = "pairwise.complete.obs")
hc <- hclust(as.dist(1 - abs(cor_noGDD)), method = "average")
clusters <- cutree(hc, h = 0.3) # 0.3 == 1 - 0.7
cluster_df <- tibble(trait = names(clusters), cluster = unname(clusters))
# 3) Absolute correlation with GDD for each trait
abs_r_GDD <- abs(cor(traits_df$GDD_5C, traits_noGDD, use = "pairwise.complete.obs"))
abs_r_GDD <- as.numeric(abs_r_GDD)
names(abs_r_GDD) <- colnames(traits_noGDD)
# 4) Max absolute correlation with any OTHER trait (redundancy metric)
max_abs_r_other <- sapply(trait_names, function(t) {
others <- setdiff(trait_names, t)
max(abs(cor_noGDD[t, others]), na.rm = TRUE)
})
# 5) Envfit R² (+ optional p) using a vegan ordination built from your dist.mat
ord <- capscale(dist.mat ~ 1) # unconstrained, PCoA-like, vegan object
ef <- envfit(ord, traits_noGDD, permutations = 10000)
r2 <- ef$vectors$r
p <- ef$vectors$pvals
# keep only continuous trait names present
r2 <- r2[trait_names]
p <- p[trait_names]
# 6) Variance (scaled data ~1, but include for completeness)
v_trait <- sapply(traits_noGDD, var, na.rm = TRUE)
# 7) Assemble an inspectable summary table (no auto-choice)
summary_tbl <- tibble(trait = trait_names, cluster = cluster_df$cluster[match(trait_names,
cluster_df$trait)], abs_r_GDD = abs_r_GDD[trait_names], max_abs_r_other = max_abs_r_other[trait_names],
envfit_R2 = r2[trait_names], envfit_p = p[trait_names], variance_scaled = v_trait[trait_names]) %>%
arrange(cluster, desc(envfit_R2))
summary_tbl
## # A tibble: 22 × 7
## trait cluster abs_r_GDD max_abs_r_other envfit_R2 envfit_p variance_scaled
## <chr> <int> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 cellulo… 1 0.0489 0.900 0.729 0.000100 1
## 2 EWT 1 0.264 0.855 0.613 0.000100 1
## 3 Cu_area 1 0.210 0.830 0.512 0.000100 1
## 4 soluble… 1 0.0526 0.988 0.467 0.000100 1
## 5 LMA 1 0.0648 0.997 0.460 0.000100 1
## 6 K_area 1 0.0805 0.806 0.454 0.000100 1
## 7 Carea 1 0.0991 0.997 0.416 0.000100 1
## 8 Narea 1 0.269 0.840 0.291 0.000100 1
## 9 LDMC 2 0.415 0.805 0.200 0.000200 1
## 10 hemicel… 3 0.177 0.607 0.0632 0.108 1
## # ℹ 12 more rows
library(dplyr)
library(tidyr)
library(corrplot)
# 1) Scale traits
traits_scaled <- scale(traits_num)
# 2) Get correlation matrix
cor_mat <- cor(traits_scaled, use = "pairwise.complete.obs", method = "pearson")
# 3) Cluster traits by correlation structure
dist_traits <- as.dist(1 - abs(cor_mat)) # distance = 1 - |r|
clust <- hclust(dist_traits, method = "average")
# 4) Cut tree at threshold for high correlation (e.g., |r| >= 0.8 means 0.2 distance)
clusters <- cutree(clust, h = 0.2)
# 5) Put into a tidy dataframe
traits_df <- data.frame(
trait = names(clusters),
cluster = clusters,
abs_r_GDD = abs(cor_mat["GDD_5C", ])
)
# 6) Pick 1 trait per cluster with highest |r| to GDD_5C
reduced_traits <- traits_df %>%
filter(trait != "GDD_5C") %>% # don't pick GDD as a "trait"
group_by(cluster) %>%
slice_max(abs_r_GDD, n = 1, with_ties = FALSE) %>%
arrange(cluster)
reduced_traits
## # A tibble: 16 × 3
## # Groups: cluster [16]
## trait cluster abs_r_GDD
## <chr> <int> <dbl>
## 1 EWT 2 0.264
## 2 LDMC 3 0.415
## 3 Narea 4 0.269
## 4 hemicellulose_area 5 0.177
## 5 lignin_area 6 0.0901
## 6 chlA_area 7 0.278
## 7 Al_area 8 0.587
## 8 Ca_area 9 0.646
## 9 Cu_area 10 0.210
## 10 Fe_area 11 0.317
## 11 K_area 12 0.0805
## 12 Mg_area 13 0.0673
## 13 Mn_area 14 0.177
## 14 Na_area 15 0.105
## 15 P_area 16 0.256
## 16 Zn_area 17 0.0207
best_per_cluster <- summary_tbl %>%
filter(envfit_p <= 0.05) %>% # drop non-significant traits
group_by(cluster) %>%
slice_max(order_by = abs_r_GDD, n = 1) %>%
ungroup()
best_per_cluster
## # A tibble: 8 × 7
## trait cluster abs_r_GDD max_abs_r_other envfit_R2 envfit_p variance_scaled
## <chr> <int> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 Narea 1 0.269 0.840 0.291 0.000100 1
## 2 LDMC 2 0.415 0.805 0.200 0.000200 1
## 3 chlA_area 5 0.278 0.977 0.279 0.000200 1
## 4 Ca_area 6 0.646 0.756 0.369 0.000100 1
## 5 Mg_area 7 0.0673 0.566 0.234 0.000200 1
## 6 Mn_area 8 0.177 0.631 0.655 0.000100 1
## 7 Na_area 9 0.105 0.596 0.184 0.00140 1
## 8 Zn_area 11 0.0207 0.478 0.0998 0.0268 1
best_per_cluster2 <- summary_tbl %>%
filter(envfit_p <= 0.05) %>% # keep significant traits only
group_by(cluster) %>%
slice_max(order_by = envfit_R2, n = 1) %>%
ungroup()
best_per_cluster2
## # A tibble: 8 × 7
## trait cluster abs_r_GDD max_abs_r_other envfit_R2 envfit_p variance_scaled
## <chr> <int> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 cellulos… 1 0.0489 0.900 0.729 0.000100 1
## 2 LDMC 2 0.415 0.805 0.200 0.000200 1
## 3 car_area 5 0.258 0.961 0.347 0.000100 1
## 4 Ca_area 6 0.646 0.756 0.369 0.000100 1
## 5 Mg_area 7 0.0673 0.566 0.234 0.000200 1
## 6 Mn_area 8 0.177 0.631 0.655 0.000100 1
## 7 Na_area 9 0.105 0.596 0.184 0.00140 1
## 8 Zn_area 11 0.0207 0.478 0.0998 0.0268 1
# Perform PERMANOVA with interaction term
permanova_beta_traits <- adonis2(dist.mat ~ Species + GDD_5C + Species:GDD_5C + LMA +
EWT + cellulose_area + Narea + Carea + Mg_area + Fe_area + chlA_area, data = asv_scaled_noPlants_Phen_filt_LMM,
permutations = 10000, strata = asv_scaled_noPlants_Phen_filt_LMM$Plant_ID, by = "term")
# Print the PERMANOVA results
print(permanova_beta_traits)
## Permutation test for adonis under reduced model
## Terms added sequentially (first to last)
## Blocks: strata
## Permutation: free
## Number of permutations: 10000
##
## adonis2(formula = dist.mat ~ Species + GDD_5C + Species:GDD_5C + LMA + EWT + cellulose_area + Narea + Carea + Mg_area + Fe_area + chlA_area, data = asv_scaled_noPlants_Phen_filt_LMM, permutations = 10000, by = "term", strata = asv_scaled_noPlants_Phen_filt_LMM$Plant_ID)
## Df SumOfSqs R2 F Pr(>F)
## Species 1 3.3505 0.10984 9.1860 9.999e-05 ***
## GDD_5C 1 1.2520 0.04105 3.4326 9.999e-05 ***
## LMA 1 0.5978 0.01960 1.6389 0.0437 *
## EWT 1 0.4507 0.01478 1.2358 0.1543
## cellulose_area 1 0.3672 0.01204 1.0068 0.4198
## Narea 1 0.4797 0.01573 1.3152 0.0269 *
## Carea 1 0.3907 0.01281 1.0711 0.1614
## Mg_area 1 0.4893 0.01604 1.3414 0.0105 *
## Fe_area 1 0.4297 0.01409 1.1780 0.2611
## chlA_area 1 0.4385 0.01437 1.2021 0.1671
## Species:GDD_5C 1 0.7371 0.02417 2.0210 0.0017 **
## Residual 59 21.5197 0.70550
## Total 70 30.5028 1.00000
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# group 1 = design; group 2 = traits
varpart(dist.mat, ~Species + GDD_5C + Species:GDD_5C, ~LMA + Narea + EWT + Mg_area +
Carea + chlA_area, data = asv_scaled_noPlants_Phen_filt_LMM)
##
## Partition of squared Bray distance in dbRDA
##
## Call: varpart(Y = dist.mat, X = ~Species + GDD_5C + Species:GDD_5C,
## ~LMA + Narea + EWT + Mg_area + Carea + chlA_area, data =
## asv_scaled_noPlants_Phen_filt_LMM)
##
## Explanatory tables:
## X1: ~Species + GDD_5C + Species:GDD_5C
## X2: ~LMA + Narea + EWT + Mg_area + Carea + chlA_area
##
## No. of explanatory tables: 2
## Total variation (SS): 30.503
## No. of observations: 71
##
## Partition table:
## Df R.squared Adj.R.squared Testable
## [a+c] = X1 3 0.18755 0.15117 TRUE
## [b+c] = X2 6 0.20016 0.12517 TRUE
## [a+b+c] = X1+X2 9 0.26888 0.16101 TRUE
## Individual fractions
## [a] = X1|X2 3 0.03584 TRUE
## [b] = X2|X1 6 0.00984 TRUE
## [c] 0 0.11533 FALSE
## [d] = Residuals 0.83899 FALSE
## ---
## Use function 'dbrda' to test significance of fractions of interest
# Fit environmental trait vectors onto ordination axes
#traits <- pcoa.table_phenology_filtered %>%
# dplyr::select(LMA, Narea, Mg_area)
traits <- pcoa.table_phenology_filtered %>%
dplyr::select(LMA, Narea, cellulose_area, Narea, Carea, Mg_area, Fe_area, chlA_area)
ordination_axes <- pcoa.table_phenology_filtered[, c("Axis.1", "Axis.2")]
fit_traits <- envfit(ordination_axes, traits, permutations = 10000, na.rm = TRUE)
# Get vector scores (envfit vectors) as a matrix
trait_scores <- scores(fit_traits, display = "vectors") # already a matrix
# Get significant traits only
sig_traits <- names(which(fit_traits$vectors$pvals < 0.05))
# Subset the matrix directly
trait_scores_df <- as.data.frame(trait_scores[sig_traits, , drop = FALSE])
# Add rownames as a column for labeling
trait_scores_df$trait <- rownames(trait_scores_df)
#trait_scores_df$trait[trait_scores_df$trait == "Narea"] <- "N_area"
# Optional: scale arrows
scaling_factor <- 0.75
trait_scores_df$Axis.1 <- trait_scores_df$Axis.1 * scaling_factor
trait_scores_df$Axis.2 <- trait_scores_df$Axis.2 * scaling_factor
Phenology_beta_traits <- Phenology_beta_nosize3 +
geom_segment(
data = trait_scores_df,
aes(x = 0, y = 0, xend = Axis.1, yend = Axis.2),
arrow = arrow(length = unit(0.15, "cm")),
color = "blue",
inherit.aes = FALSE
) +
geom_text(
data = trait_scores_df,
aes(
x = ifelse(trait == "cellulose_area", Axis.1 + 0.02,
ifelse(trait == "LMA", Axis.1 - 0.02,
ifelse(trait == "Carea", Axis.1 - 0.02,
ifelse(trait == "chlA_area", Axis.1 - 0.05,
ifelse(trait == "Narea", Axis.1 - 0.035,
ifelse(trait == "Mg_area", Axis.1 + 0.02,
Axis.1)))))), # default if none match
y = ifelse(trait == "cellulose_area", Axis.2 - 0.02,
ifelse(trait == "Fe_area", Axis.2 - 0.02,
ifelse(trait == "Carea", Axis.2 - 0.01,
ifelse(trait == "Mg_area", Axis.2 + 0.03,
ifelse(trait == "LMA", Axis.2 + 0.015,
Axis.2))))), # default
label = trait
),
size = 2,
color = "blue",
inherit.aes = FALSE
)
Phenology_beta_traits
# For envfit() stats for vectors
fit_traits
##
## ***VECTORS
##
## Axis.1 Axis.2 r2 Pr(>r)
## LMA -0.99857 -0.05348 0.4598 9.999e-05 ***
## Narea -0.92120 0.38909 0.2914 9.999e-05 ***
## cellulose_area -0.99694 -0.07823 0.7288 9.999e-05 ***
## Carea -0.99584 -0.09115 0.4165 9.999e-05 ***
## Mg_area 0.97915 0.20313 0.2340 5e-04 ***
## Fe_area -0.89028 -0.45541 0.3197 9.999e-05 ***
## chlA_area -0.96377 0.26674 0.2786 9.999e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## Permutation: free
## Number of permutations: 10000
# Filter data for Betula_populifolia
betula_data <- asv_scaled_noPlants_Phen_filt_LMM[asv_scaled_noPlants_Phen_filt_LMM$Species ==
"Betula_populifolia", ]
# Perform PERMANOVA for Betula_populifolia
permanova_betula_traits <- adonis2(dist.mat_betula ~ GDD_5C + Plant_ID + Plant_ID:GDD_5C +
LMA + EWT + cellulose_area + Narea + Carea + Mg_area + Fe_area + chlA_area, data = betula_data,
permutations = 10000, strata = betula_data$Plant_ID, by = "term")
# Print PERMANOVA results for Betula_populifolia
print(permanova_betula_traits)
## Permutation test for adonis under reduced model
## Terms added sequentially (first to last)
## Blocks: strata
## Permutation: free
## Number of permutations: 10000
##
## adonis2(formula = dist.mat_betula ~ GDD_5C + Plant_ID + Plant_ID:GDD_5C + LMA + EWT + cellulose_area + Narea + Carea + Mg_area + Fe_area + chlA_area, data = betula_data, permutations = 10000, by = "term", strata = betula_data$Plant_ID)
## Df SumOfSqs R2 F Pr(>F)
## GDD_5C 1 1.8143 0.14952 5.9705 9.999e-05 ***
## Plant_ID 4 1.3944 0.11492 1.1472 0.007399 **
## LMA 1 0.3464 0.02855 1.1400 0.283472
## EWT 1 0.2441 0.02012 0.8033 0.665133
## cellulose_area 1 0.3699 0.03048 1.2171 0.218878
## Narea 1 0.3579 0.02950 1.1779 0.250575
## Carea 1 0.2198 0.01812 0.7234 0.736526
## Mg_area 1 0.4920 0.04054 1.6190 0.074693 .
## Fe_area 1 0.2935 0.02419 0.9658 0.464154
## chlA_area 1 0.1780 0.01467 0.5856 0.911309
## GDD_5C:Plant_ID 4 1.2582 0.10369 1.0352 0.385061
## Residual 17 5.1660 0.42572
## Total 34 12.1346 1.00000
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
################################################################### Betula:
# Create a column `GDD_5C_bins` to bin (categorize) continuous GDDs
sampling_points <- c(437, 605, 1087, 1606, 1992, 2140, 2219)
data_betula$GDD_5C_bins <- cut(data_betula$GDD_5C, breaks = c(-Inf, sampling_points,
Inf), labels = c("437", "605", "1087", "1606", "1992", "2140", "2219", "2220+"),
include.lowest = TRUE)
asv_betula <- data_betula[rowSums(data_betula[, grepl("ASV", colnames(data_betula))]) !=
0, ]
distance = "bray"
dist.mat_betula <- vegan::vegdist(asv_betula[, grepl("ASV", colnames(asv_betula))],
method = distance)
pcoa_betula <- pcoa(dist.mat_betula)
pcoa.table_betula <- cbind(pcoa_betula$vectors[, 1:5], asv_betula[, !grepl("ASV",
colnames(asv_betula))])
pcoa.table_betula$Axis.1
## [1] 0.32185084 -0.15542618 0.07119949 0.38373670 0.05637697 0.22631012
## [7] 0.30710593 -0.48474348 0.35024649 0.38398583 -0.38182276 -0.06819215
## [13] -0.13753924 0.37157771 -0.35463606 -0.46884942 0.28697350 0.13971448
## [19] 0.40502434 -0.37168145 0.29766773 -0.34680044 0.34265923 0.07813432
## [25] -0.39687777 0.04950438 -0.03379417 -0.30411283 0.17149765 -0.35018965
## [31] -0.23630624 0.36823035 -0.40533706 -0.23225121 0.11676406
# Define the sampling points for GDD
sampling_points <- c(437, 605, 1087, 1606, 1992, 2140, 2219)
# Define custom shapes for each unique GDD_5C_bins value
shapes <- c(21, 22, 23, 18, 17, 15, 8) # Example shapes
# Define custom colors for each unique GDD_5C_bins value
colors <- c("royalblue", "cyan4", "goldenrod2")
pcoa.table_betula$Phen_Period <- cut(pcoa.table_betula$GDD_5C, breaks = c(-Inf, 1087,
1992, Inf), labels = c("Early-Mid", "Mid-Late", "Late-Senescence"), include.lowest = TRUE,
right = FALSE)
traits_betula <- pcoa.table_betula %>%
dplyr::select(LMA, EWT, cellulose_area, Narea, Carea, Mg_area, Fe_area, chlA_area)
ordination_axes_betula <- pcoa.table_betula[, c("Axis.1", "Axis.2")]
fit_traits_betula <- envfit(ordination_axes_betula, traits_betula, permutations = 10000,
na.rm = TRUE)
# extract vector scores and keep only significant traits
trait_scores_betula <- scores(fit_traits_betula, display = "vectors")
sig_traits_betula <- names(which(fit_traits_betula$vectors$pvals < 0.05))
# sig_traits_betula <- unique(c(sig_traits_betula, 'cellulose_area'))
trait_scores_df_betula <- as.data.frame(trait_scores_betula[sig_traits_betula, ,
drop = FALSE])
trait_scores_df_betula$trait <- rownames(trait_scores_df_betula)
# trait_scores_df_pop$trait[trait_scores_df_pop$trait == 'Narea'] <- 'N_area'
# scale the arrows so they fit nicely on the ordination
scaling_factor <- 0.75
trait_scores_df_betula$Axis.1 <- trait_scores_df_betula$Axis.1 * scaling_factor
trait_scores_df_betula$Axis.2 <- trait_scores_df_betula$Axis.2 * scaling_factor
# ---- compute sensible plotting limits so arrows/labels are not clipped ----
# get ranges from points and arrow endpoints
pt_x <- pcoa.table_betula$Axis.1
pt_y <- pcoa.table_betula$Axis.2
arrow_x <- trait_scores_df_betula$Axis.1
arrow_y <- trait_scores_df_betula$Axis.2
max_x <- max(abs(c(pt_x, arrow_x)), na.rm = TRUE) * 1.15
max_y <- max(abs(c(pt_y, arrow_y)), na.rm = TRUE) * 1.15
# put label a bit beyond the arrow tip (e.g. 5% further out)
label_df <- trait_scores_df_betula
label_df$Axis.1 <- label_df$Axis.1 * 1.13
label_df$Axis.2 <- label_df$Axis.2 * 1.13
# ---- recreate the plot and add trait arrows + labels ----
betula_beta_traits <- ggplot(pcoa.table_betula, aes(x = Axis.1, y = Axis.2)) + geom_point(aes(color = Phen_Period,
shape = GDD_5C_bins), size = 3) + stat_ellipse(aes(color = Phen_Period), level = 0.95,
linetype = "dashed") + labs(color = "General Phenological Period", shape = expression("GDD (" *
T[base] * " = 5" ~ degree * C * ")"), x = "Axis 1 [7.54%]", y = "Axis 2 [5.96%]") +
guides(color = guide_legend(order = 1), shape = guide_legend(order = 1)) + scale_shape_manual(values = shapes) +
scale_color_manual(values = c("royalblue", "cyan4", "goldenrod2")) + theme_cowplot(12) +
theme(axis.title.x = element_text(size = 8), axis.title.y = element_text(size = 8),
axis.text.x = element_text(size = 6), axis.text.y = element_text(size = 6),
legend.title = element_text(size = 8), legend.text = element_text(size = 8),
panel.border = element_rect(color = "black", size = 1, fill = NA), axis.ticks = element_line(color = "black")) +
geom_segment(data = trait_scores_df_betula, aes(x = 0, y = 0, xend = Axis.1,
yend = Axis.2), arrow = arrow(length = unit(0.15, "cm")), color = "blue",
inherit.aes = FALSE) + geom_text(data = label_df, aes(x = Axis.1, y = Axis.2,
label = trait), color = "blue", size = 2, inherit.aes = FALSE)
betula_beta_traits
# For envfit() stats for vectors
fit_traits_betula
##
## ***VECTORS
##
## Axis.1 Axis.2 r2 Pr(>r)
## LMA 0.29131 0.95663 0.2282 0.0162984 *
## EWT 0.96880 0.24783 0.2999 0.0043996 **
## cellulose_area 0.78448 0.62016 0.2026 0.0261974 *
## Narea 0.73523 0.67781 0.3968 0.0005000 ***
## Carea 0.18178 0.98334 0.2345 0.0130987 *
## Mg_area -0.00819 0.99997 0.2280 0.0158984 *
## Fe_area -0.71144 0.70275 0.2133 0.0190981 *
## chlA_area 0.95023 0.31155 0.3599 0.0005999 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## Permutation: free
## Number of permutations: 10000
# Filter data for Populus_tremuloides
populus_data <- asv_scaled_noPlants_Phen_filt_LMM[asv_scaled_noPlants_Phen_filt_LMM$Species ==
"Populus_tremuloides", ]
# Perform PERMANOVA for Populus_tremuloides
permanova_populus_beta <- adonis2(dist.mat_populus ~ GDD_5C + Plant_ID + Plant_ID:GDD_5C +
LMA + EWT + cellulose_area + solubles_area + Narea + Carea + Mg_area + Fe_area +
chlA_area, data = populus_data, permutations = 10000, strata = populus_data$Plant_ID,
by = "term")
# Print PERMANOVA results for Populus_tremuloides
print(permanova_populus_beta)
## Permutation test for adonis under reduced model
## Terms added sequentially (first to last)
## Blocks: strata
## Permutation: free
## Number of permutations: 10000
##
## adonis2(formula = dist.mat_populus ~ GDD_5C + Plant_ID + Plant_ID:GDD_5C + LMA + EWT + cellulose_area + solubles_area + Narea + Carea + Mg_area + Fe_area + chlA_area, data = populus_data, permutations = 10000, by = "term", strata = populus_data$Plant_ID)
## Df SumOfSqs R2 F Pr(>F)
## GDD_5C 1 0.5559 0.03702 1.3196 0.01460 *
## Plant_ID 4 1.5715 0.10464 0.9326 0.05859 .
## LMA 1 0.3820 0.02544 0.9068 0.80962
## EWT 1 0.3714 0.02473 0.8817 0.84622
## cellulose_area 1 0.5026 0.03347 1.1930 0.06689 .
## solubles_area 1 0.3811 0.02537 0.9046 0.84302
## Narea 1 0.7344 0.04890 1.7433 0.00050 ***
## Carea 1 0.3941 0.02625 0.9356 0.69183
## Mg_area 1 0.4215 0.02807 1.0005 0.45655
## Fe_area 1 0.4103 0.02732 0.9739 0.57374
## chlA_area 1 0.4603 0.03065 1.0927 0.19128
## GDD_5C:Plant_ID 4 1.6712 0.11128 0.9918 0.53545
## Residual 17 7.1615 0.47687
## Total 35 15.0177 1.00000
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
################################################################### Populus:
# Create a column `GDD_5C_bins` to bin (categorize) continuous GDDs
sampling_points <- c(437, 605, 1087, 1606, 1992, 2140, 2219)
data_populus$GDD_5C_bins <- cut(data_populus$GDD_5C, breaks = c(-Inf, sampling_points,
Inf), labels = c("437", "605", "1087", "1606", "1992", "2140", "2219", "2220+"),
include.lowest = TRUE)
asv_populus <- data_populus[rowSums(data_populus[, grepl("ASV", colnames(data_populus))]) !=
0, ]
distance = "bray"
dist.mat_populus <- vegan::vegdist(asv_populus[, grepl("ASV", colnames(asv_populus))],
method = distance)
pcoa_populus <- pcoa(dist.mat_populus)
pcoa.table_populus <- cbind(pcoa_populus$vectors[, 1:5], asv_populus[, !grepl("ASV",
colnames(asv_populus))])
pcoa.table_populus$Axis.1
## [1] 0.264271426 0.060279730 0.073692690 0.110784243 -0.059836302
## [6] 0.243980186 0.197052405 0.160926482 -0.037283798 0.058222492
## [11] 0.134516141 -0.102407686 -0.062668510 0.137074869 0.004128356
## [16] 0.106592222 -0.383186479 0.056580432 0.108662063 -0.176767075
## [21] 0.229669966 -0.347136308 0.008312481 -0.172540180 -0.247250789
## [26] 0.174599804 -0.250380029 0.015794125 -0.135971520 -0.030012080
## [31] 0.060872084 -0.201046955 0.325211607 0.104412843 -0.320320207
## [36] -0.108828730
# Define the sampling points for GDD
sampling_points <- c(437, 605, 1087, 1606, 1992, 2140, 2219)
# Define custom shapes for each unique GDD_5C_bins value
shapes <- c(21, 22, 23, 18, 17, 15, 8) # Example shapes
# Define custom colors for each unique GDD_5C_bins value
colors <- c("royalblue", "cyan4", "goldenrod2")
pcoa.table_populus$Phen_Period <- cut(pcoa.table_populus$GDD_5C, breaks = c(-Inf,
1087, 1992, Inf), labels = c("Early-Mid", "Mid-Late", "Late-Senescence"), include.lowest = TRUE,
right = FALSE)
traits_populus <- pcoa.table_populus %>%
dplyr::select(LMA, EWT, cellulose_area, solubles_area, Narea, Carea, Mg_area,
Fe_area, chlA_area)
ordination_axes_populus <- pcoa.table_populus[, c("Axis.1", "Axis.2")]
fit_traits_populus <- envfit(ordination_axes_populus, traits_populus, permutations = 10000,
na.rm = TRUE)
# extract vector scores and keep only significant traits
trait_scores_populus <- scores(fit_traits_populus, display = "vectors")
sig_traits_populus <- names(which(fit_traits_populus$vectors$pvals < 0.05))
# sig_traits_populus <- unique(c(sig_traits_populus, 'cellulose_area'))
trait_scores_df_populus <- as.data.frame(trait_scores_populus[sig_traits_populus,
, drop = FALSE])
trait_scores_df_populus$trait <- rownames(trait_scores_df_populus)
# trait_scores_df_pop$trait[trait_scores_df_pop$trait == 'Narea'] <- 'N_area'
# scale the arrows so they fit nicely on the ordination
scaling_factor <- 0.75
trait_scores_df_populus$Axis.1 <- trait_scores_df_populus$Axis.1 * scaling_factor
trait_scores_df_populus$Axis.2 <- trait_scores_df_populus$Axis.2 * scaling_factor
# ---- compute sensible plotting limits so arrows/labels are not clipped ----
# get ranges from points and arrow endpoints
pt_x <- pcoa.table_populus$Axis.1
pt_y <- pcoa.table_populus$Axis.2
arrow_x <- trait_scores_df_populus$Axis.1
arrow_y <- trait_scores_df_populus$Axis.2
max_x <- max(abs(c(pt_x, arrow_x)), na.rm = TRUE) * 1.15
max_y <- max(abs(c(pt_y, arrow_y)), na.rm = TRUE) * 1.15
# put label a bit beyond the arrow tip (e.g. 5% further out)
label_df <- trait_scores_df_populus
label_df$Axis.1 <- label_df$Axis.1 * 1.13
label_df$Axis.2 <- label_df$Axis.2 * 1.13
# ---- recreate the plot and add trait arrows + labels ----
populus_beta_traits <- ggplot(pcoa.table_populus, aes(x = Axis.1, y = Axis.2)) +
geom_point(aes(color = Phen_Period, shape = GDD_5C_bins), size = 3) + stat_ellipse(aes(color = Phen_Period),
level = 0.95, linetype = "dashed") + labs(color = "General Phenological Period",
shape = expression("GDD (" * T[base] * " = 5" ~ degree * C * ")"), x = "Axis 1 [7.54%]",
y = "Axis 2 [5.96%]") + guides(color = guide_legend(order = 1), shape = guide_legend(order = 1)) +
scale_shape_manual(values = shapes) + scale_color_manual(values = c("royalblue",
"cyan4", "goldenrod2")) + theme_cowplot(12) + theme(axis.title.x = element_text(size = 8),
axis.title.y = element_text(size = 8), axis.text.x = element_text(size = 6),
axis.text.y = element_text(size = 6), legend.title = element_text(size = 8),
legend.text = element_text(size = 8), panel.border = element_rect(color = "black",
size = 1, fill = NA), axis.ticks = element_line(color = "black")) + geom_segment(data = trait_scores_df_populus,
aes(x = 0, y = 0, xend = Axis.1, yend = Axis.2), arrow = arrow(length = unit(0.15,
"cm")), color = "blue", inherit.aes = FALSE) + geom_text(data = label_df,
aes(x = Axis.1, y = Axis.2, label = trait), color = "blue", size = 2, inherit.aes = FALSE)
populus_beta_traits
# For envfit() stats for vectors
fit_traits_populus
##
## ***VECTORS
##
## Axis.1 Axis.2 r2 Pr(>r)
## LMA 0.88812 0.45962 0.0128 0.8098
## EWT 0.97433 -0.22514 0.1142 0.1352
## cellulose_area 0.67565 0.73722 0.0616 0.3556
## solubles_area 0.71243 0.70174 0.0190 0.7351
## Narea 0.99304 0.11780 0.2115 0.0174 *
## Carea 0.93746 0.34809 0.0221 0.6915
## Mg_area 0.61810 -0.78610 0.0082 0.8735
## Fe_area -0.88541 0.46480 0.0294 0.6191
## chlA_area 0.69317 0.72078 0.0679 0.3132
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## Permutation: free
## Number of permutations: 10000
# Arrange the plots in a grid betaDiv_intra_combined <-
# arrangeGrob(betula_beta_pcoa_intra, populus_beta_pcoa_intra, ncol=1, nrow=2)
# Save the combined plot ggsave('betaDiv_intra_combined.jpg',
# betaDiv_intra_combined, width=7, height=7)
# OR?:
## WITH GENERAL PHEN PERIODS:
library(gridExtra)
library(grid)
# Arrange the plots in a grid with labels
betaDiv_intra_combined_traits <- arrangeGrob(grobs = list(arrangeGrob(betula_beta_traits,
top = textGrob("A", x = unit(0, "npc"), y = unit(1, "npc"), just = c("left",
"top"), gp = gpar(fontsize = 30, fontface = "bold"))), arrangeGrob(populus_beta_traits,
top = textGrob("B", x = unit(0, "npc"), y = unit(1, "npc"), just = c("left",
"top"), gp = gpar(fontsize = 30, fontface = "bold")))), ncol = 1, nrow = 2)
# Save
ggsave("betaDiv_intra_combined_traits.tiff", betaDiv_intra_combined_traits, width = 7,
height = 9.7, units = "in", dpi = 600, compression = "lzw", device = "tiff")
ggsave("betaDiv_intra_combined_traits.png", betaDiv_intra_combined_traits, width = 7,
height = 9.7, units = "in", dpi = 600)
ggsave("betaDiv_intra_combined_traits.pdf", betaDiv_intra_combined_traits, width = 7,
height = 9.7, units = "in", dpi = 600)
alpha_combined <- arrangeGrob(Phenology_richness_gddspec2, Phenology_diversity_gddspec2,
ncol = 2, nrow = 1)
# fig_div_combined_traits <- arrangeGrob(alpha_combined, Phenology_beta_traits,
# ncol=1, nrow=2)
fig_div_combined_traits <- arrangeGrob(grobs = list(arrangeGrob(alpha_combined, top = textGrob("A",
x = unit(0, "npc"), y = unit(1, "npc"), just = c("left", "top"), gp = gpar(fontsize = 30,
fontface = "bold"))), arrangeGrob(Phenology_beta_traits, top = textGrob("B",
x = unit(0, "npc"), y = unit(1, "npc"), just = c("left", "top"), gp = gpar(fontsize = 30,
fontface = "bold")))), ncol = 1, nrow = 2)
# Save
ggsave("fig_div_combined_traits.tiff", fig_div_combined_traits, width = 7, height = 7,
units = "in", dpi = 600, compression = "lzw", device = "tiff")
ggsave("fig_div_combined_traits.png", fig_div_combined_traits, width = 7, height = 7,
units = "in", dpi = 600)
ggsave("fig_div_combined_traits.pdf", fig_div_combined_traits, width = 7, height = 7,
units = "in", dpi = 600)
######################################
## Visualizing GDD Accumulation Curve
######################################
# 1. Convert Sampling Date to Date type
asv_scaled_noPlants_Phen_filt_LMM$Date <- as.Date(
asv_scaled_noPlants_Phen_filt_LMM$`Collection-Date-All`,
format = "%m/%d/%Y"
)
# 2. Aggregate if needed (but in your case, you can likely use raw rows directly)
# Otherwise, average per sampling date:
gdd_df <- asv_scaled_noPlants_Phen_filt_LMM %>%
dplyr::group_by(Date) %>%
dplyr::summarise(GDD_5C = mean(GDD_5C, na.rm = TRUE))
sampling_dates <- as.Date(c("6/8/2018", "6/21/2018", "7/19/2018", "8/16/2018", "9/11/2018", "9/24/2018", "10/8/2018"), format = "%m/%d/%Y")
# 3. Plot with continuous x-axis and LOESS smoother
library(mgcv)
## Loading required package: nlme
##
## Attaching package: 'nlme'
## The following object is masked from 'package:lme4':
##
## lmList
## The following object is masked from 'package:dplyr':
##
## collapse
## The following object is masked from 'package:Biostrings':
##
## collapse
## The following object is masked from 'package:IRanges':
##
## collapse
## This is mgcv 1.9-1. For overview type 'help("mgcv-package")'.
gdd_vs_time_plot <- ggplot(gdd_df, aes(x = Date, y = GDD_5C)) +
geom_vline(xintercept = sampling_dates,
linetype = "dashed",
color = "black",
size = 0.4) +
geom_point(size = 1) +
geom_smooth(method = "gam",
formula = y ~ s(x, bs = "cs", k = 7), # limit spline basis
se = FALSE, color = "blue", size = 0.5) +
labs(
x = "Sampling Date",
y = expression("Growing Degree Days (" * T[base] * " = 5"~degree*C * ")")
) +
scale_y_continuous(limits = c(0, NA), expand = c(0, 0)) +
scale_x_date(expand = c(0, 0), date_labels = "%b %d") +
theme_minimal() +
theme(
panel.border = element_rect(color = "black", size = 0.5, fill = NA),
panel.grid = element_blank(),
panel.background = element_rect(fill = "white", color = NA),
axis.ticks.length = unit(0.2, "cm"),
axis.ticks = element_line(color = "black", size = 0.5),
axis.title.x = element_text(size = 8.5),
axis.title.y = element_text(size = 8.5),
axis.text.x = element_text(size = 7.5),
axis.text.y = element_text(size = 7.5),
plot.margin = unit(c(1, 1, 1, 1), "pt"),
plot.background = element_rect(fill = "white", color = NA),
) +
coord_cartesian(clip = "off")
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
## Warning: The `size` argument of `element_line()` is deprecated as of ggplot2 3.4.0.
## ℹ Please use the `linewidth` argument instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
gdd_vs_time_plot
# Save
ggsave("gdd_vs_time_plot.tiff", gdd_vs_time_plot, width = 7, height = 5, units = "in",
dpi = 600, compression = "lzw", device = "tiff")
ggsave("gdd_vs_time_plot.png", gdd_vs_time_plot, width = 7, height = 5, units = "in",
dpi = 600)
library(tidyverse)
library(spaa)
# 1. Extract ASV columns
asv_cols <- grep("^ASV", names(asv_scaled_noPlants_Phen_filt_LMM), value = TRUE)
# 2. Ensure GDD_5C_bins is present
stopifnot("GDD_5C" %in% names(asv_scaled_noPlants_Phen_filt_LMM))
# 3. Aggregate ASV abundances by GDD bin
agg_data <- asv_scaled_noPlants_Phen_filt_LMM %>%
dplyr::select(GDD_5C, all_of(asv_cols)) %>%
dplyr::group_by(GDD_5C) %>%
dplyr::summarise(across(everything(), sum, na.rm = TRUE)) %>%
dplyr::ungroup()
## Warning: There was 1 warning in `dplyr::summarise()`.
## ℹ In argument: `across(everything(), sum, na.rm = TRUE)`.
## ℹ In group 1: `GDD_5C = 437`.
## Caused by warning:
## ! The `...` argument of `across()` is deprecated as of dplyr 1.1.0.
## Supply arguments directly to `.fns` through an anonymous function instead.
##
## # Previously
## across(a:b, mean, na.rm = TRUE)
##
## # Now
## across(a:b, \(x) mean(x, na.rm = TRUE))
# 4. Convert to community matrix: rows = GDD bins, cols = ASVs
comm_matrix <- as.data.frame(agg_data)
rownames(comm_matrix) <- comm_matrix$GDD_5C
comm_matrix$GDD_5C <- NULL
# 5. Call niche.width()
niche_result <- niche.width(comm_matrix, method = "levins")
# 6. Tidy result
niche_df <- tibble(ASV = colnames(comm_matrix), NicheWidth = as.numeric(niche_result))
# 7. View
print(niche_df)
## # A tibble: 1,732 × 2
## ASV NicheWidth
## <chr> <dbl>
## 1 ASV7 3.16
## 2 ASV8 2.53
## 3 ASV9 3.17
## 4 ASV10 5.87
## 5 ASV12 2.54
## 6 ASV13 Inf
## 7 ASV14 3.34
## 8 ASV15 Inf
## 9 ASV16 1
## 10 ASV17 2.19
## # ℹ 1,722 more rows
library(tidyverse)
# 1. Start from your scaled data
asv_data <- asv_scaled_noPlants_Phen_filt_LMM
asv_cols <- grep("^ASV", names(asv_data), value = TRUE)
# 2. Get Levins' niche width
agg_data <- asv_data %>%
dplyr::select(GDD_5C, all_of(asv_cols)) %>%
dplyr::group_by(GDD_5C) %>%
dplyr::summarise(across(everything(), sum, na.rm = TRUE)) %>%
dplyr::ungroup()
# Build matrix in the correct orientation: rows = GDD, columns = ASVs
mat <- asv_scaled_noPlants_Phen_filt_LMM %>%
dplyr::select(GDD_5C, all_of(asv_cols)) %>%
dplyr::group_by(GDD_5C) %>%
dplyr::summarise(across(everything(), sum), .groups = "drop") %>%
column_to_rownames("GDD_5C") %>%
as.matrix()
# No transpose needed here! Columns = ASVs (good)
niche_result <- niche.width(mat, method = "levins")
# Convert to tibble
niche_result_df <- tibble(
ASV = colnames(mat), # Get proper ASV IDs
NicheWidth = as.numeric(niche_result)
)
# 4. Classify
#quantiles <- quantile(niche_result_df$NicheWidth, probs = c(0.33, 0.66), na.rm = TRUE)
#niche_result_df <- niche_result_df %>%
# mutate(Class = case_when(
# NicheWidth <= quantiles[1] ~ "Specialist",
# NicheWidth >= quantiles[2] ~ "Generalist",
# TRUE ~ "Intermediate"
# ))
library(ggplot2)
# Assuming your niche widths are stored in niche_result_df$NicheWidth
ggplot(niche_result_df, aes(x = NicheWidth)) + geom_histogram(binwidth = 0.25, fill = "steelblue",
color = "black") + geom_vline(xintercept = c(1.5, 2.5), linetype = "dashed",
color = "red") + labs(title = "Distribution of ASV Thermal Niche Widths (Levins')",
x = "Levins' Niche Width", y = "Count of ASVs") + theme_minimal()
## Warning: Removed 26 rows containing non-finite outside the scale range
## (`stat_bin()`).
niche_result_df <- niche_result_df %>%
mutate(Class = case_when(NicheWidth <= 1.5 ~ "Specialist", NicheWidth >= 2.25 ~
"Generalist", TRUE ~ "Intermediate"))
# 5. Recompute abundance across GDDs for each ASV
asv_long <- asv_data %>%
dplyr::select(GDD_5C, all_of(asv_cols)) %>%
tidyr::pivot_longer(cols = all_of(asv_cols), names_to = "ASV", values_to = "Abundance")
# Confirm that 'ASV' and 'Abundance' exist
print(colnames(asv_long))
## [1] "GDD_5C" "ASV" "Abundance"
# Add relative abundance per ASV
asv_long <- asv_long %>%
group_by(ASV) %>%
mutate(RelAbund = Abundance/sum(Abundance)) %>%
ungroup()
# 6. Identify ASVs that are 75%+ abundant in just one GDD
specialized_gdds <- asv_long %>%
filter(RelAbund > 0.7) %>%
dplyr::select(ASV, GDD_5C, RelAbund)
# 7. Merge with niche width and class
final_niche_df_threshold <- niche_result_df %>%
left_join(specialized_gdds, by = "ASV") %>%
arrange(NicheWidth)
final_niche_df_threshold
## # A tibble: 1,732 × 5
## ASV NicheWidth Class GDD_5C RelAbund
## <chr> <dbl> <chr> <dbl> <dbl>
## 1 ASV16 1 Specialist NA NA
## 2 ASV30 1 Specialist NA NA
## 3 ASV34 1 Specialist NA NA
## 4 ASV38 1 Specialist NA NA
## 5 ASV43 1 Specialist NA NA
## 6 ASV53 1 Specialist NA NA
## 7 ASV63 1 Specialist NA NA
## 8 ASV77 1 Specialist NA NA
## 9 ASV86 1 Specialist NA NA
## 10 ASV89 1 Specialist NA NA
## # ℹ 1,722 more rows
# Start clean
library(tidyverse)
# 1. Input data
asv_data <- asv_scaled_noPlants_Phen_filt_LMM
asv_cols <- grep("^ASV", names(asv_data), value = TRUE)
# 2. Niche width matrix (GDD × ASVs)
mat <- asv_data %>%
dplyr::select(GDD_5C, all_of(asv_cols)) %>%
dplyr::group_by(GDD_5C) %>%
dplyr::summarise(across(everything(), sum), .groups = "drop") %>%
column_to_rownames("GDD_5C") %>%
as.matrix()
# 3. Calculate Levins' niche width
niche_result <- niche.width(mat, method = "levins")
# 4. Make into tibble
niche_result_df <- tibble(ASV = colnames(mat), NicheWidth = as.numeric(niche_result))
# 5. Recompute abundance across GDDs
asv_long <- asv_data %>%
dplyr::select(GDD_5C, all_of(asv_cols)) %>%
pivot_longer(cols = all_of(asv_cols), names_to = "ASV", values_to = "Abundance") %>%
group_by(ASV) %>%
mutate(RelAbund = Abundance/sum(Abundance)) %>%
ungroup()
# 6. Find peak GDD bin per ASV
gdd_peaks <- asv_long %>%
group_by(ASV) %>%
slice_max(order_by = RelAbund, n = 1, with_ties = FALSE) %>%
dplyr::select(ASV, GDD_5C, RelAbund) %>%
dplyr::rename(GDD_peak = GDD_5C)
# 7. Merge and classify
finite_niches <- niche_result_df %>%
filter(is.finite(NicheWidth))
# quantiles <- quantile(finite_niches$NicheWidth, probs = c(0.33, 0.66))
# final_niche_df_no_threshold <- niche_result_df %>% left_join(gdd_peaks, by =
# 'ASV') %>% mutate(Class = case_when( is.infinite(NicheWidth) ~ 'Undefined',
# NicheWidth <= quantiles[1] ~ 'Specialist', NicheWidth >= quantiles[2] ~
# 'Generalist', TRUE ~ 'Intermediate' ))
final_niche_df_no_threshold <- niche_result_df %>%
left_join(gdd_peaks, by = "ASV") %>%
mutate(Class = case_when(NicheWidth <= 1.5 ~ "Specialist", NicheWidth >= 2.25 ~
"Generalist", TRUE ~ "Intermediate"))
final_niche_df_no_threshold
## # A tibble: 1,732 × 5
## ASV NicheWidth GDD_peak RelAbund Class
## <chr> <dbl> <dbl> <dbl> <chr>
## 1 ASV7 3.16 2219 0.0249 Generalist
## 2 ASV8 2.53 2219 0.0215 Generalist
## 3 ASV9 3.17 2219 0.0181 Generalist
## 4 ASV10 5.87 2140 0.00956 Generalist
## 5 ASV12 2.54 1606 0.0164 Generalist
## 6 ASV13 Inf 1087 0 Generalist
## 7 ASV14 3.34 1992 0.0138 Generalist
## 8 ASV15 Inf 1087 0 Generalist
## 9 ASV16 1 1992 0.0000226 Specialist
## 10 ASV17 2.19 2140 0.0154 Intermediate
## # ℹ 1,722 more rows
# 8. Double check
final_niche_df_no_threshold %>%
dplyr::filter(!is.na(GDD_peak)) %>%
dplyr::group_by(Class) %>%
dplyr::summarise(n = n())
## # A tibble: 3 × 2
## Class n
## <chr> <int>
## 1 Generalist 212
## 2 Intermediate 177
## 3 Specialist 1343
niche_props_all <- final_niche_df_no_threshold %>%
dplyr::filter(!is.na(GDD_peak)) %>%
dplyr::count(Class) %>%
dplyr::mutate(perc = round(100 * n/sum(n), 1))
ggplot(niche_props_all, aes(x = Class, y = perc, fill = Class)) + geom_col() + geom_text(aes(label = paste0(perc,
"% (n=", n, ")")), vjust = -0.3, size = 3) + scale_fill_manual(values = c(Specialist = "orangered",
Generalist = "blue", Intermediate = "grey", Undefined = "black")) + theme_minimal() +
theme(axis.title.x = element_text(size = 9), axis.title.y = element_text(size = 9),
axis.text.x = element_text(size = 8), axis.text.y = element_text(size = 8),
legend.position = "none", panel.border = element_rect(color = "black", size = 1,
fill = NA), panel.grid = element_blank(), panel.background = element_rect(fill = "white",
color = NA), axis.ticks = element_line(color = "black"), plot.margin = unit(c(0.6,
0.6, 0.5, 5), "pt")) + labs(y = "Proportion of ASVs (%)", x = "Thermal Niche Class")
library(spaa)
library(tidyverse)
# For each host species, calculate niche width
calc_species_niche_width <- function(df, species_name) {
df_species <- df %>%
filter(species == species_name)
# Pivot to wide GDD × ASV format
mat_df <- df_species %>%
group_by(GDD_5C) %>%
dplyr::summarise(across(starts_with("ASV"), sum), .groups = "drop")
mat <- as.matrix(column_to_rownames(mat_df, var = "GDD_5C"))
# Calculate niche width
niche_vals <- niche.width(mat, method = "levins")
# Classify
df_out <- tibble(ASV = names(niche_vals), NicheWidth = as.numeric(niche_vals))
# quantiles <- quantile(df_out$NicheWidth, probs = c(0.33, 0.66), na.rm =
# TRUE)
df_out <- df_out %>%
mutate(Class = case_when(NicheWidth < 1.5 ~ "Specialist", NicheWidth > 2.25 ~
"Generalist", TRUE ~ "Intermediate"), species = species_name)
return(df_out)
}
# Run it for both species
betula_niche <- calc_species_niche_width(ps_df, "Betula populifolia Marshall")
populus_niche <- calc_species_niche_width(ps_df, "Populus tremuloides Michaux")
# Combine
species_niche_df <- bind_rows(betula_niche, populus_niche)
niche_counts_sp <- species_niche_df %>%
dplyr::group_by(species, Class) %>%
dplyr::summarise(n = n(), .groups = "drop")
niche_counts_sp
## # A tibble: 6 × 3
## species Class n
## <chr> <chr> <int>
## 1 Betula populifolia Marshall Generalist 960
## 2 Betula populifolia Marshall Intermediate 86
## 3 Betula populifolia Marshall Specialist 686
## 4 Populus tremuloides Michaux Generalist 754
## 5 Populus tremuloides Michaux Intermediate 115
## 6 Populus tremuloides Michaux Specialist 863
niche_props_matched <- species_niche_df %>%
dplyr::filter(is.finite(NicheWidth)) %>%
dplyr::distinct(ASV, .keep_all = TRUE) %>%
dplyr::count(Class) %>%
dplyr::mutate(perc = round(100 * n/sum(n), 1))
ggplot(niche_props_matched, aes(x = Class, y = perc, fill = Class)) + geom_col() +
geom_text(aes(label = paste0(perc, "% (n=", n, ")")), vjust = -0.3, size = 3) +
scale_fill_manual(values = c(Specialist = "orangered", Generalist = "blue", Intermediate = "grey")) +
labs(x = "Thermal Niche Class", y = "Proportion of ASVs (%)") + theme_minimal() +
theme(axis.title = element_text(size = 9), axis.text = element_text(size = 8),
panel.border = element_rect(color = "black", size = 1, fill = NA), panel.grid = element_blank(),
axis.ticks = element_line(color = "black"), legend.position = "none", plot.margin = unit(c(0.6,
0.6, 0.5, 5), "pt"))
# Step 1: Summarize mean niche width per ASV (across species)
niche_df_summary <- species_niche_df %>%
dplyr::filter(is.finite(NicheWidth)) %>%
dplyr::group_by(ASV, Class) %>%
dplyr::summarise(MeanNicheWidth = mean(NicheWidth, na.rm = TRUE), .groups = "drop")
# Step 2: Count ASVs per Class
niche_props_matched <- niche_df_summary %>%
dplyr::count(Class) %>%
dplyr::mutate(perc = round(100 * n/sum(n), 1))
# Step 3: Plot
niche_proportions_total_asvs_filt <- ggplot(niche_props_matched, aes(x = Class, y = perc,
fill = Class)) + geom_col() + geom_text(aes(label = paste0(perc, "% (n=", n,
")")), vjust = -0.3, size = 3) + scale_fill_manual(values = c(Specialist = "orangered",
Generalist = "blue", Intermediate = "grey")) + labs(x = "Thermal Niche Class",
y = "Proportion of ASVs (%)") + theme_minimal() + theme(axis.title = element_text(size = 9),
axis.text = element_text(size = 8), panel.border = element_rect(color = "black",
size = 1, fill = NA), panel.grid = element_blank(), axis.ticks = element_line(color = "black"),
legend.position = "none", plot.margin = unit(c(0.6, 0.6, 0.5, 5), "pt"))
niche_proportions_total_asvs_filt
# Save
ggsave("niche_proportions_total_asvs_filt.tiff", niche_proportions_total_asvs_filt,
width = 7, height = 7, units = "in", dpi = 600, compression = "lzw", device = "tiff")
ggsave("niche_proportions_total_asvs_filt.png", niche_proportions_total_asvs_filt,
width = 7, height = 7, units = "in", dpi = 600)
ggsave("niche_proportions_total_asvs_filt.pdf", niche_proportions_total_asvs_filt,
width = 7, height = 7, units = "in", dpi = 600)
species_niche_df_summary <- species_niche_df %>%
dplyr::filter(is.finite(NicheWidth)) %>%
dplyr::group_by(ASV, species, Class) %>%
dplyr::summarise(
MeanNicheWidth = mean(NicheWidth, na.rm = TRUE),
.groups = "drop"
)
niche_props_sp <- species_niche_df_summary %>%
dplyr::count(species, Class) %>%
dplyr::group_by(species) %>%
dplyr::mutate(perc = round(100 * n / sum(n), 1)) %>%
dplyr::ungroup() %>%
dplyr::mutate(species = dplyr::recode(species,
"Betula populifolia Marshall" = "Grey Birch",
"Populus tremuloides Michaux" = "Trembling Aspen"
))
niche_proportions_sp_filt <- ggplot(niche_props_sp, aes(x = Class, y = perc, fill = Class)) +
geom_col() +
geom_text(aes(label = paste0(perc, "%")), vjust = -0.4, size = 2) +
facet_wrap(~ species) +
scale_fill_manual(values = c(
"Specialist" = "orangered",
"Generalist" = "blue",
"Intermediate" = "grey"
)) +
theme_minimal() +
theme(
strip.background = element_rect(fill = "grey90", color = "black", size = 0.5), # ← this line
strip.text = element_text(size = 8, face = "bold"),
axis.title.x = element_text(size = 7),
axis.title.y = element_text(size = 7),
axis.text.x = element_text(angle = 25, vjust = 1.15, hjust = 1.2, size = 6),
axis.text.y = element_text(size = 6),
legend.position = "none",
panel.border = element_rect(color = "black", size = 1, fill = NA),
panel.grid = element_blank(),
panel.background = element_rect(fill = "white", color = NA),
axis.ticks = element_line(color = "black"),
plot.margin = unit(c(0.5, 0.5, 0.5, 0.5), "pt")
) +
labs(
y = "Proportion of ASVs (%)",
x = "Thermal Niche Class"
)
niche_proportions_sp_filt
# Generalists only:
generalists_df <- species_niche_df %>%
dplyr::filter(Class == "Generalist") %>%
dplyr::mutate(species = dplyr::recode(species, `Betula populifolia Marshall` = "Grey Birch",
`Populus tremuloides Michaux` = "Trembling Aspen"))
# Specialists:
specialists_df <- species_niche_df %>%
dplyr::filter(Class == "Specialist") %>%
dplyr::mutate(species = dplyr::recode(species, `Betula populifolia Marshall` = "Grey Birch",
`Populus tremuloides Michaux` = "Trembling Aspen"))
# Wilcoxon test (non-parametric)
wilcox.test(NicheWidth ~ species, data = generalists_df)
##
## Wilcoxon rank sum test with continuity correction
##
## data: NicheWidth by species
## W = 367782, p-value = 0.2703
## alternative hypothesis: true location shift is not equal to 0
wilcox.test(NicheWidth ~ species, data = specialists_df)
##
## Wilcoxon rank sum test with continuity correction
##
## data: NicheWidth by species
## W = 298490, p-value = 0.3805
## alternative hypothesis: true location shift is not equal to 0
# Create a contingency table
table_df_niche_diffs <- species_niche_df_summary %>%
dplyr::filter(Class %in% c("Generalist", "Specialist")) %>%
dplyr::mutate(species = dplyr::recode(species, `Betula populifolia Marshall` = "Grey Birch",
`Populus tremuloides Michaux` = "Trembling Aspen")) %>%
dplyr::count(species, Class) %>%
tidyr::pivot_wider(names_from = species, values_from = n, values_fill = 0) %>%
tibble::column_to_rownames("Class")
# Apply Fisher's Exact Test or Chi-squared test
fisher.test(table_df_niche_diffs)
##
## Fisher's Exact Test for Count Data
##
## data: table_df_niche_diffs
## p-value = 0.05362
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
## 0.9834183 1.8933002
## sample estimates:
## odds ratio
## 1.363852
# OR
chisq.test(table_df_niche_diffs)
##
## Pearson's Chi-squared test with Yates' continuity correction
##
## data: table_df_niche_diffs
## X-squared = 3.4564, df = 1, p-value = 0.06301
library(tidyverse)
# 1. Input your full ps_df (wide format, has ASV columns, OTU = ASV, Genus, Sample, Abundance, GDD_5C_bins)
# ---------------------------------------------------------------
asv_cols <- grep("^ASV", names(ps_df), value = TRUE)
# 2. Build the abundance matrix at GDD × ASV
# ---------------------------------------------------------------
mat <- ps_df %>%
dplyr::ungroup() %>% # In case it's grouped by Sample
dplyr::select(GDD_5C, all_of(asv_cols)) %>%
dplyr::group_by(GDD_5C) %>%
dplyr::summarise(across(everything(), sum, na.rm = TRUE), .groups = "drop") %>%
column_to_rownames("GDD_5C") %>%
as.matrix()
# 3. Compute Levins' niche width
# ---------------------------------------------------------------
library(spaa)
niche_result <- niche.width(mat, method = "levins")
niche_result_df <- tibble(
ASV = colnames(mat),
NicheWidth = as.numeric(niche_result)
)
# 4. Calculate relative abundance + GDD peak for each ASV
# ---------------------------------------------------------------
asv_long <- ps_df %>%
dplyr::select(GDD_5C, GDD_5C_bins, species, OTU, all_of(asv_cols)) %>%
pivot_longer(cols = all_of(asv_cols), names_to = "ASV", values_to = "Abundance") %>%
group_by(ASV) %>%
mutate(RelAbund = Abundance / sum(Abundance)) %>%
ungroup()
## Adding missing grouping variables: `Sample`
gdd_peaks <- asv_long %>%
group_by(ASV) %>%
slice_max(RelAbund, n = 1, with_ties = FALSE) %>%
dplyr::select(ASV, GDD_5C, RelAbund) %>%
dplyr::rename(GDD_peak = GDD_5C)
# 5. Get Genus mapping
# ---------------------------------------------------------------
genus_map <- ps_df %>%
dplyr::select(ASV = OTU, Genus) %>%
distinct()
## Adding missing grouping variables: `Sample`
# 6. Merge everything + classify niche breadth
# ---------------------------------------------------------------
finite_niches <- niche_result_df %>% filter(is.finite(NicheWidth))
final_niche_genus_df <- niche_result_df %>%
left_join(gdd_peaks, by = "ASV") %>%
left_join(genus_map, by = "ASV") %>%
mutate(
Genus = ifelse(is.na(Genus), "Unclassified", Genus),
Class = case_when(
is.infinite(NicheWidth) ~ "Undefined",
NicheWidth <= 1.5 ~ "Specialist",
NicheWidth >= 2.25 ~ "Generalist",
TRUE ~ "Intermediate"
)
)
# 7. Quick summary table (optional)
# ---------------------------------------------------------------
final_niche_genus_df %>%
dplyr::filter(!is.na(GDD_peak)) %>%
dplyr::group_by(Class) %>%
dplyr::summarise(n = n())
## # A tibble: 4 × 2
## Class n
## <chr> <int>
## 1 Generalist 13206
## 2 Intermediate 12567
## 3 Specialist 95353
## 4 Undefined 1846
# 8. View or save your final result
# ---------------------------------------------------------------
View(final_niche_genus_df)
# Or save:
# write_csv(final_niche_genus_df, "niche_genus_gdd_results.csv")
# STEP 1: Genus Mapping
asv_to_genus <- ps_df %>%
dplyr::ungroup() %>%
dplyr::select(OTU, Genus) %>%
dplyr::distinct() %>%
dplyr::rename(ASV = OTU)
# STEP 2: Annotate Niche Table (FILTERED for finite values)
final_niche_df_annotated <- final_niche_df_no_threshold %>%
filter(is.finite(NicheWidth)) %>%
left_join(asv_to_genus, by = "ASV")
# STEP 3: (Optional) Focus on key genera focus_genera <- c('Endobacter',
# '1174-901-12', 'P3OB-42', 'Massilia') # example key_taxa_niche <-
# final_niche_df_annotated %>% filter(Genus %in% focus_genera)
final_niche_df_annotated
## # A tibble: 1,706 × 6
## ASV NicheWidth GDD_peak RelAbund Class Genus
## <chr> <dbl> <dbl> <dbl> <chr> <chr>
## 1 ASV7 3.16 2219 0.0249 Generalist Endobacter
## 2 ASV8 2.53 2219 0.0215 Generalist Endobacter
## 3 ASV9 3.17 2219 0.0181 Generalist 1174-901-12
## 4 ASV10 5.87 2140 0.00956 Generalist <NA>
## 5 ASV12 2.54 1606 0.0164 Generalist Staphylococcus
## 6 ASV14 3.34 1992 0.0138 Generalist 1174-901-12
## 7 ASV16 1 1992 0.0000226 Specialist Escherichia-Shigella
## 8 ASV17 2.19 2140 0.0154 Intermediate Massilia
## 9 ASV19 4.42 2140 0.00740 Generalist <NA>
## 10 ASV22 1.66 2219 0.000782 Intermediate Pelomonas
## # ℹ 1,696 more rows
# View the full annotated table
key_taxa_niche <- final_niche_df_annotated
key_taxa_niche
## # A tibble: 1,706 × 6
## ASV NicheWidth GDD_peak RelAbund Class Genus
## <chr> <dbl> <dbl> <dbl> <chr> <chr>
## 1 ASV7 3.16 2219 0.0249 Generalist Endobacter
## 2 ASV8 2.53 2219 0.0215 Generalist Endobacter
## 3 ASV9 3.17 2219 0.0181 Generalist 1174-901-12
## 4 ASV10 5.87 2140 0.00956 Generalist <NA>
## 5 ASV12 2.54 1606 0.0164 Generalist Staphylococcus
## 6 ASV14 3.34 1992 0.0138 Generalist 1174-901-12
## 7 ASV16 1 1992 0.0000226 Specialist Escherichia-Shigella
## 8 ASV17 2.19 2140 0.0154 Intermediate Massilia
## 9 ASV19 4.42 2140 0.00740 Generalist <NA>
## 10 ASV22 1.66 2219 0.000782 Intermediate Pelomonas
## # ℹ 1,696 more rows
# Rename columns before writing
final_niche_table <- final_niche_df_annotated %>%
dplyr::rename(`GDD Peak` = GDD_peak, `Niche Width` = NicheWidth, `Relative Abundance` = RelAbund,
`Levin's Niche Class` = Class)
# Save to CSV
write.csv(final_niche_table, "NicheWidth_Table_Annotated.csv", row.names = FALSE)
# 1. Input your full ps_df (wide format, has ASV columns, OTU = ASV, Genus, Sample, Abundance, GDD_5C_bins)
# ---------------------------------------------------------------
asv_cols <- grep("^ASV", names(ps_df), value = TRUE)
# Use asv_long + niche widths
asv_long %>%
left_join(final_niche_df_annotated, by = "ASV") %>%
filter(Abundance > 0) %>% # Only include ASVs active in that GDD bin
filter(is.finite(NicheWidth)) %>%
ggplot(aes(x = factor(GDD_5C_bins), y = NicheWidth)) +
geom_boxplot(fill = "skyblue") +
geom_hline(yintercept = 1.5, linetype = "dashed", color = "orangered", linewidth = 0.6) +
geom_hline(yintercept = 2.25, linetype = "dashed", color = "blue", linewidth = 0.6) +
annotate("text", x = Inf, y = 1.5, label = NULL,
hjust = 1.05, vjust = -0.5, size = 3.2, color = "orangered") +
annotate("text", x = Inf, y = 2.25, label = NULL,
hjust = 1.05, vjust = -0.5, size = 3.2, color = "blue") +
labs(x = "GDD", y = "Levins' Niche Width",
title = "ASV Niche Widths of Active Taxa Across GDDs") +
theme_minimal()
library(tidyverse)
# 1. ASV to long format
asv_cols <- grep("^ASV", names(ps_df), value = TRUE)
asv_long2 <- ps_df %>%
dplyr::select(GDD_5C, GDD_5C_bins, species, Collection.Month, OTU, all_of(asv_cols)) %>%
pivot_longer(cols = all_of(asv_cols), names_to = "ASV", values_to = "Abundance") %>%
group_by(ASV) %>%
mutate(RelAbund = Abundance/sum(Abundance)) %>%
ungroup()
## Adding missing grouping variables: `Sample`
# 2. Join & format
plot_data <- asv_long2 %>%
left_join(final_niche_df_annotated, by = "ASV") %>%
filter(!is.na(species), Abundance > 0, is.finite(NicheWidth)) %>%
mutate(species = case_when(species == "Betula populifolia Marshall" ~ "Grey Birch",
species == "Populus tremuloides Michaux" ~ "Trembling Aspen", TRUE ~ species),
GDD_5C_bins = factor(GDD_5C_bins))
# 3. Base colors
species_colors <- c(`Grey Birch` = "#ecb21e", `Trembling Aspen` = "purple")
collection_month_colors <- c(`6` = "seagreen2", `7` = "orange", `8` = "lightcoral",
`9` = "deepskyblue", `10` = "orchid")
# 4. Grey bars
grey_rects <- data.frame(xmin = seq(1.5, length(levels(plot_data$GDD_5C_bins)) -
0.5, by = 2), xmax = seq(2.5, length(levels(plot_data$GDD_5C_bins)) + 0.5, by = 2))
# 5. Month color bars
collection_month_bars <- plot_data %>%
distinct(GDD_5C_bins, Collection.Month) %>%
mutate(xmin = as.numeric(GDD_5C_bins) - 0.5, xmax = as.numeric(GDD_5C_bins) +
0.5)
# 6. Plot
niche_width_hostspecies_gdds <- ggplot(plot_data, aes(x = GDD_5C_bins, y = NicheWidth,
fill = species)) + geom_rect(data = collection_month_bars, aes(xmin = xmin, xmax = xmax,
ymin = 0, ymax = 1, fill2 = as.factor(Collection.Month)), inherit.aes = FALSE,
fill = collection_month_colors[collection_month_bars$Collection.Month], show.legend = FALSE) +
geom_rect(data = grey_rects, aes(xmin = xmin, xmax = xmax, ymin = 1, ymax = Inf),
fill = "grey90", inherit.aes = FALSE) + geom_boxplot(position = position_dodge(width = 0.78),
size = 0.25, fatten = 3) + geom_hline(yintercept = 1.5, linetype = "dashed",
color = "orangered", linewidth = 0.85) + geom_hline(yintercept = 2.25, linetype = "dashed",
color = "blue", linewidth = 0.85) + scale_fill_manual(values = species_colors,
name = "Host Species") + coord_cartesian(ylim = c(1, 6)) + labs(x = expression("Growing Degree Days (" *
T[base] * " = 5" ~ degree * C * ")"), y = "Levins' Niche Width") + guides(fill = guide_legend(nrow = 1,
title = "Host Species", keyheight = unit(0.3, "cm"), keywidth = unit(0.3, "cm"))) +
theme_cowplot(12) + theme(legend.position = "bottom", legend.box = "horizontal",
axis.title.x = element_text(size = 7), axis.title.y = element_text(size = 7),
axis.text.x = element_text(size = 6), axis.text.y = element_text(size = 6), legend.title = element_text(size = 6),
legend.text = element_text(size = 6), panel.border = element_rect(color = "black",
size = 0.5, fill = NA), plot.margin = unit(c(0.5, 0.5, 0.5, 0.5), "pt"))
## Warning in geom_rect(data = collection_month_bars, aes(xmin = xmin, xmax =
## xmax, : Ignoring unknown aesthetics: fill2
niche_width_hostspecies_gdds
# 1. Join Genus info
asv_to_genus <- ps_df %>%
dplyr::ungroup() %>%
dplyr::select(OTU, Genus) %>%
dplyr::distinct() %>%
dplyr::rename(ASV = OTU)
# final_niche_df_annotated <- final_niche_df_no_threshold %>%
# left_join(asv_to_genus, by = 'ASV')
# 2. Filter for focal genera
focus_genera <- c("Endobacter", "1174-901-12", "P3OB-42", "Methylocella", "Kineococcus",
"Massilia", "Pseudomonas", "Blastococcus", "Nocardioides", "Frondihabitans",
"Methylobacterium-Methylorubrum")
key_taxa_niche <- final_niche_df_annotated %>%
filter(Genus %in% focus_genera, is.finite(NicheWidth))
key_taxa_niche_plot <- ggplot(key_taxa_niche, aes(x = Genus, y = NicheWidth, fill = Genus)) +
geom_boxplot(size = 0.25, fatten = 3) + geom_hline(yintercept = 1.5, linetype = "dashed",
color = "orangered", linewidth = 0.85) + geom_hline(yintercept = 2.25, linetype = "dashed",
color = "blue", linewidth = 0.85) + annotate("text", x = Inf, y = 1.5, label = NULL,
hjust = 1.05, vjust = -0.5, size = 3.2, color = "orangered") + annotate("text",
x = Inf, y = 2.25, label = NULL, hjust = 1.05, vjust = -0.5, size = 3.2, color = "blue") +
scale_fill_manual(values = c(Endobacter = "olivedrab", `1174-901-12` = "brown",
`P3OB-42` = "deepskyblue2", Methylocella = "mediumblue", Kineococcus = "yellow3",
Massilia = "cyan", Pseudomonas = "orchid3", Blastococcus = "tan", Nocardioides = "purple4",
Frondihabitans = "seagreen2", `Methylobacterium-Methylorubrum` = "turquoise4"),
labels = function(x) {
x <- str_replace(x, "Methylobacterium-Methylorubrum", "Methylobacterium-\nMethylorubrum")
x
}) + labs(x = "Genus", y = "Levins' Niche Width") + guides(fill = guide_legend(keyheight = 0.75,
keywidth = 0.75, ncol = 1)) + scale_x_discrete(labels = function(x) {
x <- str_replace(x, "Methylobacterium-Methylorubrum", "Methylobacterium-\nMethylorubrum")
x
}) + theme_minimal() + theme(axis.title.x = element_text(size = 7), axis.title.y = element_text(size = 7),
axis.text.x = element_text(angle = 45, vjust = 1.15, hjust = 1.2, size = 6),
axis.text.y = element_text(size = 6), axis.ticks = element_line(color = "black"),
panel.border = element_rect(color = "black", size = 1, fill = NA), panel.grid = element_blank(),
plot.margin = unit(c(0.5, 0.5, 0.5, 0.5), "pt"), legend.text = element_text(size = 7),
legend.position = "none")
key_taxa_niche_plot
# 1. Define ASVs of interest and desired order
focus_asvs <- c("ASV8", "ASV91", "ASV10", "ASV35", "ASV9", "ASV14", "ASV28", "ASV143", "ASV64", "ASV160", "ASV41", "ASV58", "ASV97", "ASV62", "ASV106", "ASV197", "ASV140", "ASV235", "ASV365", "ASV162")
order_asvs_niche <- focus_asvs
# 2. Create lookup table for ASV → Genus
asv_to_genus <- tibble(
ASV = focus_asvs,
Genus = c("Endobacter", "Endobacter", "Unclassified", "Unclassified", "1174-901-12", "1174-901-12", "P3OB-42", "P3OB-42", "Methylocella", "Methylocella", "Methylobacterium-Methylorubrum", "Methylobacterium-Methylorubrum", "Massilia", "Massilia", "Blastococcus", "Kineococcus", "Pseudomonas", "Nocardioides", "Nocardioides", "Frondihabitans")
)
# 3. Define colors by Genus
genus_colors_niche <- c(
"Endobacter" = "olivedrab",
"1174-901-12" = "brown",
"Unclassified" = "darkgrey",
"P3OB-42" = "deepskyblue",
"Methylocella" = "mediumblue",
"Massilia" = "cyan",
"Blastococcus" = "tan",
"Kineococcus" = "yellow3",
"Pseudomonas" = "orchid",
"Nocardioides" = "purple4",
"Frondihabitans" = "seagreen2",
"Methylobacterium-Methylorubrum" = "turquoise4"
)
# 4. Join and fix Genus column
key_asvs_niche <- final_niche_df_annotated %>%
filter(ASV %in% focus_asvs, is.finite(NicheWidth)) %>%
left_join(asv_to_genus, by = "ASV") %>%
mutate(
Genus = coalesce(Genus.y, Genus.x), # Prefer right-join genus
Genus = ifelse(is.na(Genus), "Unclassified", Genus), # Force label for NA
ASV = factor(ASV, levels = order_asvs_niche)
) %>%
dplyr::select(-Genus.x, -Genus.y) # Cleanup
# 5. Plot by Genus (not ASV)
key_asvs_niche_plot <- ggplot(key_asvs_niche, aes(x = ASV, y = NicheWidth, fill = Genus)) +
geom_bar(stat = "identity", color = "black") +
scale_fill_manual(values = genus_colors_niche,
labels = function(x) {
x <- str_replace(x, "Methylobacterium-Methylorubrum", "Methylobacterium-\nMethylorubrum")
x
}) +
geom_hline(yintercept = 1.5, linetype = "dashed", color = "orangered", linewidth = 0.85) +
geom_hline(yintercept = 2.25, linetype = "dashed", color = "blue", linewidth = 0.85) +
annotate("text", x = Inf, y = 1.5, label = NULL,
hjust = 1.05, vjust = -0.5, size = 3.2, color = "orangered") +
annotate("text", x = Inf, y = 2.25, label = NULL,
hjust = 1.05, vjust = -0.5, size = 3.2, color = "blue") +
labs(
x = "ASV", y = "Levins' Niche Width",
fill = "Genus"
) +
theme_minimal() +
guides(fill = guide_legend(keyheight = 0.45, keywidth = 0.45, ncol = 1)) +
theme(
axis.text.x = element_text(size = 6, angle = 45, hjust = 1),
axis.title.x = element_text(size = 7),
axis.title.y = element_text(size = 7),
axis.text.y = element_text(size = 6),
axis.ticks = element_line(color = "black"),
legend.title = element_text(size = 6),
legend.text = element_text(size = 6),
legend.position = c(0.999, 0.999),
legend.justification = c("right", "top"),
legend.box.background = element_rect(
fill = NA,
color = "black",
size = 0.25
),
legend.box.margin = margin(t = 0, r = 0, b = 0, l = 0, unit = "lines"),
panel.border = element_rect(color = "black", fill = NA, size = 1),
panel.grid = element_blank(),
plot.margin = unit(c(0.5, 0.5, 0.5, 0.5), "pt")
)
## Warning: A numeric `legend.position` argument in `theme()` was deprecated in ggplot2
## 3.5.0.
## ℹ Please use the `legend.position.inside` argument of `theme()` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
key_asvs_niche_plot
niche_plots_combined <- arrangeGrob(niche_proportions_sp_filt, niche_width_hostspecies_gdds,
key_taxa_niche_plot, key_asvs_niche_plot, ncol = 2, nrow = 2)
# Save
ggsave("niche_plots_combined.tiff", niche_plots_combined, width = 7, height = 7,
units = "in", dpi = 600, compression = "lzw", device = "tiff")
ggsave("niche_plots_combined.png", niche_plots_combined, width = 7, height = 7, units = "in",
dpi = 600)
ggsave("niche_plots_combined.pdf", niche_plots_combined, width = 7, height = 7, units = "in",
dpi = 600)
ggplot(species_niche_df, aes(x = species, y = NicheWidth, color = Class)) + geom_jitter(width = 0.25,
size = 2, alpha = 0.6) + stat_summary(fun = median, geom = "crossbar", width = 0.4,
color = "black") + scale_color_manual(values = c(Specialist = "red", Intermediate = "grey50",
Generalist = "blue")) + theme_minimal() + labs(x = "Host Species", y = "Levins' Niche Width",
color = "Niche Class")
## Warning: Removed 1541 rows containing non-finite outside the scale range
## (`stat_summary()`).
library(ggplot2)
niche_violin_plot <- ggplot(species_niche_df, aes(x = species, y = NicheWidth, fill = Class)) +
geom_violin(scale = "width", trim = FALSE, alpha = 0.5) + geom_jitter(width = 0.15,
size = 1, alpha = 0.4, aes(color = Class)) + scale_fill_manual(values = c(Specialist = "red",
Intermediate = "grey50", Generalist = "blue")) + scale_color_manual(values = c(Specialist = "red",
Intermediate = "grey50", Generalist = "blue")) + scale_x_discrete(labels = c(`Betula populifolia Marshall` = "Grey Birch",
`Populus tremuloides Michaux` = "Trembling Aspen")) + theme_minimal() + labs(x = "Host Species",
y = "Levins' Niche Width", fill = "Niche Class", color = "Niche Class") + theme(axis.title = element_text(size = 9),
axis.text = element_text(size = 8), legend.title = element_text(size = 8), legend.text = element_text(size = 7),
panel.border = element_rect(color = "black", fill = NA, size = 1), panel.grid = element_blank())
niche_violin_plot
## Warning: Removed 1541 rows containing non-finite outside the scale range
## (`stat_ydensity()`).
# Save
ggsave("niche_violin_plot.tiff", niche_violin_plot, width = 7, height = 7, units = "in",
dpi = 600, compression = "lzw", device = "tiff")
ggsave("niche_violin_plot.png", niche_violin_plot, width = 7, height = 7, units = "in",
dpi = 600)
ggsave("niche_violin_plot.pdf", niche_violin_plot, width = 7, height = 7, units = "in",
dpi = 600)
summary_stats_niche <- species_niche_df %>%
dplyr::mutate(Status = ifelse(is.finite(NicheWidth), "Included", "Excluded")) %>%
dplyr::count(species, Status)
summary_stats_niche
## # A tibble: 4 × 3
## species Status n
## <chr> <chr> <int>
## 1 Betula populifolia Marshall Excluded 870
## 2 Betula populifolia Marshall Included 862
## 3 Populus tremuloides Michaux Excluded 671
## 4 Populus tremuloides Michaux Included 1061
species_niche_df %>%
dplyr::filter(is.finite(NicheWidth)) %>%
dplyr::count(species)
## # A tibble: 2 × 2
## species n
## <chr> <int>
## 1 Betula populifolia Marshall 862
## 2 Populus tremuloides Michaux 1061
####################################################
species_niche_df %>%
dplyr::filter(is.finite(NicheWidth)) %>%
nrow()
## [1] 1923
species_niche_df %>%
dplyr::filter(is.finite(NicheWidth)) %>%
dplyr::distinct(ASV) %>%
nrow()
## [1] 1706
species_niche_df %>%
dplyr::filter(is.finite(NicheWidth)) %>%
dplyr::group_by(ASV) %>%
dplyr::summarise(n_species = n_distinct(species)) %>%
dplyr::filter(n_species == 2) %>%
nrow()
## [1] 217
# 1. Join Genus info
asv_to_genus <- ps_df %>%
dplyr::ungroup() %>%
dplyr::select(OTU, Genus) %>%
dplyr::distinct() %>%
dplyr::rename(ASV = OTU)
# final_niche_df_annotated <- final_niche_df_no_threshold %>%
# left_join(asv_to_genus, by = 'ASV')
# 2. Add species info and GDD bins from asv_long
niche_gen_gdds <- asv_long2 %>%
left_join(final_niche_df_annotated, by = "ASV") %>%
filter(Genus %in% c("Endobacter", "1174-901-12", "P3OB-42", "Methylocella", "Kineococcus",
"Massilia", "Pseudomonas", "Pelomonas", "Streptococcus", "Pseudarthrobacter",
"Blastococcus", "Pelomonas", "Nocardioides"), is.finite(NicheWidth), Abundance >
0) %>%
ggplot(aes(x = factor(GDD_5C_bins), y = NicheWidth, fill = Genus)) + geom_boxplot(position = position_dodge(width = 0.75),
color = "black", outlier.size = 0.5) + scale_fill_manual(values = c(Endobacter = "olivedrab",
`1174-901-12` = "brown", `P3OB-42` = "deepskyblue2", Methylocella = "blue", Kineococcus = "yellow3",
Massilia = "cyan", Pseudomonas = "orchid3", Pelomonas = "seagreen2", Streptococcus = "violetred2",
Pseudarthrobacter = "orangered", Blastococcus = "tan", Pelomonas = "skyblue4",
Nocardioides = "purple4")) + labs(x = expression("GDD Bin (" * T[base] * " = 5" ~
degree * C * ")"), y = "Levins' Niche Width") + theme_minimal() + theme(axis.text.x = element_text(angle = 45,
hjust = 1, size = 6), axis.text.y = element_text(size = 6), axis.title = element_text(size = 7),
legend.title = element_text(size = 6), legend.text = element_text(size = 6),
plot.title = element_text(size = 8, face = "bold"), panel.border = element_rect(color = "black",
size = 1, fill = NA), panel.grid = element_blank())
niche_gen_gdds
# 1. Join Genus info
asv_to_genus <- ps_df %>%
dplyr::ungroup() %>%
dplyr::select(OTU, Genus) %>%
dplyr::distinct() %>%
dplyr::rename(ASV = OTU)
final_niche_df_annotated <- final_niche_df_no_threshold %>%
left_join(asv_to_genus, by = "ASV")
# 2. Add species info and GDD bins from asv_long
asv_long %>%
left_join(final_niche_df_annotated, by = "ASV") %>%
filter(Genus %in% c("Endobacter", "1174-901-12", "P3OB-42", "Methylocella", "Kineococcus",
"Massilia", "Pseudomonas", "Pelomonas", "Streptococcus", "Pseudarthrobacter",
"Blastococcus"), is.finite(NicheWidth), Abundance > 0, !is.na(species)) %>%
mutate(species = case_when(species == "Betula populifolia Marshall" ~ "B. populifolia",
species == "Populus tremuloides Michaux" ~ "P. tremuloides", TRUE ~ species # retain original if no match
)) %>%
ggplot(aes(x = factor(GDD_5C_bins), y = NicheWidth, fill = Genus)) + geom_boxplot(position = position_dodge(width = 0.75),
color = "black", outlier.size = 0.5) + facet_wrap(~species, ncol = 1) + scale_fill_manual(values = c(Endobacter = "olivedrab",
`1174-901-12` = "brown", `P3OB-42` = "deepskyblue2", Methylocella = "blue", Kineococcus = "yellow3",
Massilia = "cyan", Pseudomonas = "orchid3", Pelomonas = "seagreen2", Streptococcus = "violetred2",
Pseudarthrobacter = "orangered", Blastococcus = "tan")) + labs(x = expression("GDD Bin (" *
T[base] * " = 5" ~ degree * C * ")"), y = "Levins' Niche Width", title = "Thermal Niche Breadth of Focal Genera by Host Across GDD Bins") +
theme_minimal() + theme(axis.text.x = element_text(angle = 45, hjust = 1, size = 6),
axis.text.y = element_text(size = 6), axis.title = element_text(size = 7), legend.title = element_text(size = 6),
legend.text = element_text(size = 6), plot.title = element_text(size = 8, face = "bold"),
panel.border = element_rect(color = "black", size = 1, fill = NA), strip.text = element_text(size = 7,
face = "bold"))
library(tidyverse)
##### NOTE: TRY USING ASVs INSTEAD OF GENERA!!!
# Define focal genera
focus_genera <- c("Endobacter", "1174-901-12", "P3OB-42", "Methylobacterium-Methylorubrum",
"Sphingomonas", "Massilia")
# 1. Join GDD + niche width + genus + abundance data
niche_lm_data <- asv_long %>%
left_join(final_niche_df_no_threshold, by = "ASV") %>%
left_join(ps_df %>%
dplyr::ungroup() %>%
dplyr::select(OTU, Genus) %>%
dplyr::distinct() %>%
dplyr::rename(ASV = OTU), by = "ASV") %>%
filter(Genus %in% focus_genera, is.finite(NicheWidth), Abundance > 0) # Only include active ASVs at that GDD
# 3. Run linear models for each genus
lm_results <- niche_lm_data %>%
dplyr::group_by(Genus) %>%
dplyr::summarise(model = list(lm(NicheWidth ~ GDD_5C)), .groups = "drop") %>%
mutate(summary = map(model, summary), slope = map_dbl(summary, ~coef(.x)[2, 1]),
p_value = map_dbl(summary, ~coef(.x)[2, 4]), r_squared = map_dbl(summary,
~.x$r.squared))
# 4. View results
lm_results %>%
dplyr::select(Genus, slope, p_value, r_squared)
ggplot(niche_lm_data, aes(x = GDD_5C, y = NicheWidth, color = Genus)) + geom_point(alpha = 0.6) +
geom_smooth(method = "lm", se = TRUE, linewidth = 0.8) + facet_wrap(~Genus, scales = "free_y") +
labs(x = expression("GDD (" * T[base] * " = 5" ~ degree * C * ")"), y = "ASV Niche Width (Levins')",
title = "Thermal Filtering of ASV Niche Width by Genus") + theme_minimal()
library(lme4)
library(performance)
library(purrr)
# Subset just your genus of interest
endobacter_df <- ps_df %>%
filter(Genus == "Endobacter")
# Define model formulas
formulas_lmm <- list(raw = RelativeAbundance ~ GDD_5C + species + species:GDD_5C +
(1 | Plant_ID), sqrt = sqrt(RelativeAbundance) ~ GDD_5C + species + species:GDD_5C +
(1 | Plant_ID), log = log1p(RelativeAbundance) ~ GDD_5C + species + species:GDD_5C +
(1 | Plant_ID))
# Fit models using purrr::map
model_results_endobacter_lmm <- purrr::map(formulas_lmm, ~lmer(.x, data = endobacter_df))
# Compare model fits
compare_performance(model_results_endobacter_lmm$raw, model_results_endobacter_lmm$sqrt,
model_results_endobacter_lmm$log)
# ASV10:
library(lme4)
library(performance)
library(purrr)
# No renaming needed — just use ASV10 directly
formulas_lmm_asv10 <- list(raw = ASV10 ~ GDD_5C + species + species:GDD_5C + (1 |
Plant_ID), sqrt = sqrt(ASV10) ~ GDD_5C + species + species:GDD_5C + (1 | Plant_ID),
log = log1p(ASV10) ~ GDD_5C + species + species:GDD_5C + (1 | Plant_ID))
# Fit models using ASV10 column from ps_df
model_results_asv10_lmm <- purrr::map(formulas_lmm_asv10, ~lmer(.x, data = ps_df))
# Compare model performance
compare_performance(model_results_asv10_lmm$raw, model_results_asv10_lmm$sqrt, model_results_asv10_lmm$log)
# Subset just your genus of interest
endobacter_df <- ps_df %>%
filter(Genus == "Endobacter")
# Define model formulas
formulas_lm <- list(raw = RelativeAbundance ~ GDD_5C * species, sqrt = sqrt(RelativeAbundance) ~
GDD_5C * species, log = log1p(RelativeAbundance) ~ GDD_5C * species)
# Fit models using purrr::map
model_results_endobacter_lm <- purrr::map(formulas_lm, ~lm(.x, data = endobacter_df))
# Compare model fits
compare_performance(model_results_endobacter_lm$raw, model_results_endobacter_lm$sqrt,
model_results_endobacter_lm$log)
# PROBABLY THIS ONE B/C BETTER FIT & SIMPLER!
## ** NOTE!!!: Sangiorgio et al. (2024): 'We calculated the Spearman’s
## correlation between temperature and relative abundance of differentially
## abundant zOTUs for beech and Scots pine, respectively. The false discovery
## rate (fdr) was applied to adjust probability (p) values for multiple
## comparisons.
lm_endobacter <- lm(RelativeAbundance ~ GDD_5C + species + species:GDD_5C, data = endobacter_df)
summary(lm_endobacter)
lm_endobacter_log <- lm(log1p(RelativeAbundance) ~ GDD_5C + species + species:GDD_5C,
data = endobacter_df)
summary(lm_endobacter_log)
library(broom)
#results_genus <- ps_df_clean %>%
# group_by(Genus) %>%
# filter(n() > 10) %>% # Optional: only test genera with enough data
# group_modify(~ tidy(lm(log1p(RelativeAbundance) ~ GDD_5C + species + GDD_5C:species, data = .x))) %>%
# ungroup()
results_genus <- ps_df %>%
group_by(Genus) %>%
filter(n() > 10) %>% # Optional: only test genera with enough data
group_modify(~ tidy(lm(log1p(RelativeAbundance) ~ GDD_5C + species + GDD_5C:species, data = .x))) %>%
ungroup()
# View just GDD effects
results_genus %>%
filter(term == "GDD_5C") %>%
arrange(p.value)
# Step 1: Filter to just GDD effects
gdd_effects <- results_genus %>%
filter(term == "GDD_5C") %>%
arrange(p.value)
# Step 2: Export to CSV
write.csv(gdd_effects, "Genus_GDD_Effects.csv", row.names = FALSE)
# r2_by_genus <- ps_df_clean %>% group_by(Genus) %>% filter(n() > 10) %>%
# group_modify(~ { model <- lm(log1p(RelativeAbundance) ~ GDD_5C + species +
# GDD_5C:species, data = .x) glance_out <- glance(model) glance_out$Genus <-
# unique(.x$Genus) glance_out }) %>% ungroup() %>% dplyr::select(Genus,
# r.squared, adj.r.squared, AIC, BIC, p.value)
r2_by_genus <- ps_df %>%
group_by(Genus) %>%
filter(n() > 10) %>%
group_modify(~{
model <- lm(log1p(RelativeAbundance) ~ GDD_5C + species + GDD_5C:species,
data = .x)
glance_out <- glance(model)
glance_out$Genus <- unique(.x$Genus)
glance_out
}) %>%
ungroup() %>%
dplyr::select(Genus, r.squared, adj.r.squared, AIC, BIC, p.value)
r2_by_genus
lm_by_genus <- ps_df %>%
group_by(Genus) %>%
filter(n() > 10) %>%
group_modify(~{
model <- lm(log1p(RelativeAbundance) ~ GDD_5C + species + GDD_5C:species,
data = .x)
glance_out <- glance(model)
glance_out$Genus <- unique(.x$Genus)
glance_out
}) %>%
ungroup() %>%
dplyr::select(Genus, r.squared, adj.r.squared, AIC, BIC, p.value)
lm_by_genus
save.image(file = "16S_analyses_full_workspace.RData")